Podman : Generate Systemd unit file2021/05/24 |
It's possible to generate Systemd unit file and set auto-starting for containers.
|
|
[1] | Set auto-starting for containers. |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/fedora-nginx latest 483f8a2536ed 16 minutes ago 428 MB registry.fedoraproject.org/fedora latest 3567369c6711 9 days ago 184 MB # run container [root@dlp ~]# podman run --name fedora-nginx -d -p 80:80 srv.world/fedora-nginx
podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a26c01180a8c srv.world/fedora-nginx /usr/sbin/nginx -... 5 minutes ago Up 5 minutes ago 0.0.0.0:80->80/tcp fedora-nginx # generate Systemd unit file [root@dlp ~]# podman generate systemd --new --files --name fedora-nginx /root/container-fedora-nginx.service cat /root/container-fedora-nginx.service # container-fedora-nginx.service # autogenerated by Podman 3.1.2 # Sun May 23 20:03:15 EDT 2021 [Unit] Description=Podman container-fedora-nginx.service Documentation=man:podman-generate-systemd(1) Wants=network.target After=network-online.target RequiresMountsFor=/var/lib/containers/storage /run/containers/storage [Service] Environment=PODMAN_SYSTEMD_UNIT=%n Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/container-fedora-nginx.pid %t/container-fedora-nginx.ctr-id ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-fedora-nginx.pid --cidfile %t/container-fedora-nginx.ctr-id --cgroups=no-conmon --replace --name fedora-nginx -d -p 80:80 srv.world/fedora-nginx ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-fedora-nginx.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-fedora-nginx.ctr-id PIDFile=%t/container-fedora-nginx.pid Type=forking [Install] WantedBy=multi-user.target default.target
[root@dlp ~]#
cp /root/container-fedora-nginx.service /usr/lib/systemd/system # enable auto-starting [root@dlp ~]# systemctl enable container-fedora-nginx.service Created symlink /etc/systemd/system/multi-user.target.wants/container-fedora-nginx.service → /usr/lib/systemd/system/container-fedora-nginx.service. Created symlink /etc/systemd/system/default.target.wants/container-fedora-nginx.service → /usr/lib/systemd/system/container-fedora-nginx.service. |
[2] | Set auto-starting for pods. |
# run Pod [root@dlp ~]# podman run -dt --pod new:nginx-pod -p 80:80 srv.world/fedora-nginx
podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 7e18be5eeeb9 nginx-pod Running 19 seconds ago 5f9b94032d6d 2 # generate Systemd unit file [root@dlp ~]# podman generate systemd --files --name nginx-pod /root/pod-nginx-pod.service /root/container-gracious_williamson.service
[root@dlp ~]#
cp /root/pod-nginx-pod.service /root/container-gracious_williamson.service /usr/lib/systemd/system # enable auto-starting [root@dlp ~]# systemctl enable pod-nginx-pod.service container-gracious_williamson.service Created symlink /etc/systemd/system/multi-user.target.wants/pod-nginx-pod.service → /usr/lib/systemd/system/pod-nginx-pod.service. Created symlink /etc/systemd/system/default.target.wants/pod-nginx-pod.service → /usr/lib/systemd/system/pod-nginx-pod.service. Created symlink /etc/systemd/system/multi-user.target.wants/container-gracious_williamson.service → /usr/lib/systemd/system/container-gracious_williamson.service. Created symlink /etc/systemd/system/default.target.wants/container-gracious_williamson.service → /usr/lib/systemd/system/container-gracious_williamson.service. |
Sponsored Link |
|