Podman : コンテナーの自動起動の設定2021/08/28 |
Systemd ユニットファイルを生成して、システム起動時にコンテナーが自動起動できるよう設定します。
|
|
[1] | コンテナーの自動起動の設定です。 |
root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/debian-nginx latest 37125087a75f 24 hours ago 216 MB docker.io/library/debian latest fe3c5de03486 11 days ago 129 MB docker.io/library/registry 2 1fd8e1b0bb7e 4 months ago 26.8 MB k8s.gcr.io/pause 3.2 80d28bedfe5d 18 months ago 688 kB # コンテナー起動 root@dlp:~# podman run --name debian-nginx -d -p 80:80 srv.world/debian-nginx
podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 18fce9406035 srv.world/debian-nginx /usr/sbin/nginx -... 5 minutes ago Up 4 seconds ago 0.0.0.0:80->80/tcp debian-nginx # Systemd ユニットファイル生成 root@dlp:~# podman generate systemd --new --files --name debian-nginx /root/container-debian-nginx.service cat /root/container-debian-nginx.service # container-debian-nginx.service # autogenerated by Podman 3.0.1 # Sat Aug 28 03:44:43 CDT 2021 [Unit] Description=Podman container-debian-nginx.service Documentation=man:podman-generate-systemd(1) Wants=network.target After=network-online.target [Service] Environment=PODMAN_SYSTEMD_UNIT=%n Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm -f %t/container-debian-nginx.pid %t/container-debian-nginx.ctr-id ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-debian-nginx.pid --cidfile %t/container-debian-nginx.ctr-id --cgroups=no-conmon --replace --name debian-nginx -d -p 80:80 srv.world/debian-nginx ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-debian-nginx.ctr-id -t 10 ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-debian-nginx.ctr-id PIDFile=%t/container-debian-nginx.pid Type=forking [Install] WantedBy=multi-user.target default.target
root@dlp:~#
cp /root/container-debian-nginx.service /usr/lib/systemd/system # 自動起動を有効化 root@dlp:~# systemctl enable container-debian-nginx.service Created symlink /etc/systemd/system/multi-user.target.wants/container-debian-nginx.service → /lib/systemd/system/container-debian-nginx.service. Created symlink /etc/systemd/system/default.target.wants/container-debian-nginx.service → /lib/systemd/system/container-debian-nginx.service. |
[2] | Pod の自動起動の設定です。 |
# Pod 起動 root@dlp:~# podman run -dt --pod new:nginx-pod -p 80:80 srv.world/debian-nginx
podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 9922d274afda nginx-pod Running 22 seconds ago 6cf5a92a0ef0 2 # Systemd ユニットファイル生成 root@dlp:~# podman generate systemd --files --name nginx-pod /root/pod-nginx-pod.service /root/container-recursing_bhabha.service
root@dlp:~#
cp /root/pod-nginx-pod.service /root/container-recursing_bhabha.service /usr/lib/systemd/system # 自動起動を有効化 root@dlp:~# systemctl enable pod-nginx-pod.service container-recursing_bhabha.service Created symlink /etc/systemd/system/multi-user.target.wants/pod-nginx-pod.service → /lib/systemd/system/pod-nginx-pod.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/multi-user.target.wants/container-recursing_bhabha.service → /lib/systemd/system/container-recursing_bhabha.service. Created symlink /etc/systemd/system/default.target.wants/container-recursing_bhabha.service → /lib/systemd/system/container-recursing_bhabha.service. |
Sponsored Link |