Podman : Generate Systemd unit file2022/04/28 |
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/ubuntu-nginx latest 00787fa1628b 2 hours ago 170 MB srv.world/ubuntu-apache2 latest c5d3a78bc38f 2 hours ago 224 MB docker.io/library/mariadb latest 7a1ace59b072 6 days ago 421 MB docker.io/library/ubuntu latest 3f4714ee068a 6 days ago 80.3 MB docker.io/library/registry 2 2e200967d166 3 weeks ago 24.7 MB k8s.gcr.io/pause 3.5 ed210e3e4a5b 13 months ago 690 kB # run container root@dlp:~# podman run --name ubuntu-nginx -d -p 80:80 srv.world/ubuntu-nginx
podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 04b8fbffb0ec srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... 5 seconds ago Up 5 seconds ago 0.0.0.0:80->80/tcp ubuntu-nginx # generate Systemd unit file root@dlp:~# podman generate systemd --new --files --name ubuntu-nginx /root/container-ubuntu-nginx.service cat /root/container-ubuntu-nginx.service # container-ubuntu-nginx.service # autogenerated by Podman 3.4.4 # Thu Apr 28 07:23:14 UTC 2022 [Unit] Description=Podman container-ubuntu-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 ubuntu-nginx -d -p 80:80 srv.world/ubuntu-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-ubuntu-nginx.service /usr/lib/systemd/system # enable auto-starting root@dlp:~# systemctl enable container-ubuntu-nginx.service Created symlink /etc/systemd/system/default.target.wants/container-ubuntu-nginx.service → /lib/systemd/system/container-ubuntu-nginx.service. |
[2] | Set auto-starting for pods. |
# run Pod root@dlp:~# podman run -dt --pod new:nginx-pod -p 80:80 srv.world/ubuntu-nginx
podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 47bcdc5af807 nginx-pod Running 4 seconds ago 8a718f12a651 2 # generate Systemd unit file root@dlp:~# podman generate systemd --files --name nginx-pod /root/container-youthful_galileo.service /root/pod-nginx-pod.service
root@dlp:~#
cp /root/pod-nginx-pod.service /root/container-youthful_galileo.service /usr/lib/systemd/system # enable auto-starting root@dlp:~# systemctl enable pod-nginx-pod.service container-youthful_galileo.service Created symlink /etc/systemd/system/default.target.wants/pod-nginx-pod.service → /lib/systemd/system/pod-nginx-pod.service. Created symlink /etc/systemd/system/default.target.wants/container-youthful_galileo.service → /lib/systemd/system/container-youthful_galileo.service. |
Sponsored Link |
|