updated notes

This commit is contained in:
Hugh Ratsch
2025-02-20 15:48:09 -06:00
parent 5e3fbf31c2
commit 9f73eb1af5
+30
View File
@@ -998,4 +998,34 @@ podman volume ls
### run the container with the volume
podman run --name mywebserver -d -p 8080:80 -v myvolume:/var/www/html:Z nginx
```
### Scheduling Containerised Services with Systemd
> Note: You can use systemd to schedule containerised services.
>> configure the service to run under a user's account even when the user is not logged into the system
```bash
### enable linger for the user
sudo loginctl enable-linger user1
### create a systemd service
mkdir -p /home/user1/.config/systemd/user
podman pull nginx
### run the container
podman run -d --name mynginx -p 8080:80 nginx
### cd into the user's home directory
cd /home/user1/.config/systemd/user
podman generate systemd --name mynginx --files --new # generate the systemd service file
### ensure the service file is wantedby default.target
[Install]
WantedBy=default.target
systemctl --user daemon-reload # reload the systemd user daemon
systemctl --user enable container-mynginx.service # enable the mynginx service
systemctl --user status container-mynginx.service # check the status of the mynginx service
### after rebooting the system, the service will start automatically
```