updated notes
This commit is contained in:
@@ -999,3 +999,33 @@ podman volume ls
|
|||||||
### run the container with the volume
|
### run the container with the volume
|
||||||
podman run --name mywebserver -d -p 8080:80 -v myvolume:/var/www/html:Z nginx
|
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
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user