Podman : Generate Systemd unit file2022/03/14 |
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/centos-nginx latest 762eb0a249a5 2 hours ago 247 MB srv.world/centos-httpd latest 0c6c507d6e95 2 hours ago 253 MB quay.io/centos/centos stream9 44ffcc4acee8 3 days ago 152 MB # run container [root@dlp ~]# podman run --name centos-nginx -d -p 80:80 srv.world/centos-nginx
podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 39ba8361888a srv.world/centos-nginx:latest /usr/sbin/nginx -... 4 seconds ago Up 4 seconds ago 0.0.0.0:80->80/tcp centos-nginx # generate Systemd unit file [root@dlp ~]# podman generate systemd --new --files --name centos-nginx /root/container-centos-nginx.service cat /root/container-centos-nginx.service # container-centos-nginx.service # autogenerated by Podman 4.0.0 # Mon Mar 14 12:58:23 JST 2022 [Unit] Description=Podman container-centos-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 centos-nginx -d -p 80:80 srv.world/centos-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-centos-nginx.service /usr/lib/systemd/system # enable auto-starting [root@dlp ~]# systemctl enable container-centos-nginx.service Created symlink /etc/systemd/system/default.target.wants/container-centos-nginx.service → /usr/lib/systemd/system/container-centos-nginx.service. |
[2] | Set auto-starting for pods. |
# run Pod [root@dlp ~]# podman run -dt --pod new:nginx-pod -p 80:80 srv.world/centos-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 |
|