Podman : コンテナーの自動起動の設定2022/03/14 |
Systemd ユニットファイルを生成して、システム起動時にコンテナーが自動起動できるよう設定します。
|
|
[1] | コンテナーの自動起動の設定です。 |
[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 # コンテナー起動 [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 # Systemd ユニットファイル生成 [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 # 自動起動を有効化 [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] | Pod の自動起動の設定です。 |
# 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 # Systemd ユニットファイル生成 [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 # 自動起動を有効化 [root@dlp ~]# systemctl enable pod-nginx-pod.service container-wizardly_bohr.service |
Sponsored Link |
|