Podman : Generate Systemd unit file2023/03/01 |
It's possible to generate Systemd unit file and set auto-starting for containers.
|
|
[1] | Generate Systemd unit file and Set auto-starting for containers. |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/almalinux-nginx latest f556ccecaed8 2 hours ago 310 MB srv.world/almalinux-httpd latest ffd19e5b5339 2 hours ago 251 MB docker.io/library/almalinux latest d3ffa43c2567 6 days ago 196 MB docker.io/library/registry 2 0d153fadf70b 2 weeks ago 24.7 MB # run container [root@dlp ~]# podman run --name almalinux-nginx -d -p 80:80 srv.world/almalinux-nginx
podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 39ba8361888a srv.world/almalinux-nginx:latest /usr/sbin/nginx -... 4 seconds ago Up 4 seconds ago 0.0.0.0:80->80/tcp almalinux-nginx # generate Systemd unit file [root@dlp ~]# podman generate systemd --new --files --name almalinux-nginx /root/container-almalinux-nginx.service cat /root/container-almalinux-nginx.service # container-almalinux-nginx.service # autogenerated by Podman 4.0.0 # Mon Mar 14 12:58:23 JST 2022 [Unit] Description=Podman container-almalinux-nginx.service Documentation=man:podman-generate-systemd(1) Wants=network-online.target After=network-online.target RequiresMountsFor=%t/containers [Service] Environment=PODMAN_SYSTEMD_UNIT=%n Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/%n.ctr-id ExecStart=/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon --replace --name almalinux-nginx -d -p 80:80 srv.world/almalinux-nginx ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id Type=notify NotifyAccess=all [Install] WantedBy=default.target
[root@dlp ~]#
cp /root/container-almalinux-nginx.service /usr/lib/systemd/system # enable auto-starting [root@dlp ~]# systemctl enable container-almalinux-nginx.service Created symlink /etc/systemd/system/default.target.wants/container-almalinux-nginx.service → /usr/lib/systemd/system/container-almalinux-nginx.service. |
[2] | Set auto-starting for pods. |
# run Pod [root@dlp ~]# podman run -dt --pod new:nginx-pod -p 80:80 srv.world/almalinux-nginx
podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 4ab1295bc57a nginx-pod Running 4 seconds ago 4c2b4c72a3df 2 # generate Systemd unit file [root@dlp ~]# podman generate systemd --files --name nginx-pod /root/pod-nginx-pod.service /root/container-wizardly_bohr.service
[root@dlp ~]#
cp /root/pod-nginx-pod.service /root/container-wizardly_bohr.service /usr/lib/systemd/system # enable auto-starting [root@dlp ~]# systemctl enable pod-nginx-pod.service container-wizardly_bohr.service |
Sponsored Link |
|