Podman : コンテナーの自動起動の設定2025/01/21 |
Systemd ユニットファイルを生成して、システム起動時にコンテナーが自動起動できるよう設定します。 |
|
[1] | Quadlet を使用したコンテナーサービスの設定です。 |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.3.1-1733097600 d6ffe53ab076 38 minutes ago 701 kB srv.world/centos-nginx latest 451cd94e6c28 54 minutes ago 347 MB docker.io/library/root-web latest 3f60fa99e10d 58 minutes ago 347 MB srv.world/iproute latest dfa2b401b86c 3 hours ago 346 MB srv.world/centos-httpd latest ff3843182253 8 hours ago 354 MB quay.io/centos/centos stream10 1ef274445e32 7 days ago 311 MB docker.io/moby/buildkit buildx-stable-1 a72f628fa83e 5 weeks ago 207 MB docker.io/library/mariadb latest 6722945a6940 2 months ago 412 MB docker.io/library/registry latest 282bd1664cf1 15 months ago 26 MB [Unit] Description=Nginx container After=local-fs.target [Container] # 任意の名称 ContainerName=centos-nginx # 使用するコンテナーイメージ Image=srv.world/centos-nginx # ポート PublishPort=80:80 [Service] Restart=always [Install] WantedBy=multi-user.target default.target systemctl daemon-reload [root@dlp ~]# systemctl start centos-nginx.service
|
[2] | Quadlet を使用した Pod サービスの設定です。 |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.3.1-1733097600 d6ffe53ab076 39 minutes ago 701 kB srv.world/centos-nginx latest 451cd94e6c28 56 minutes ago 347 MB docker.io/library/root-web latest 3f60fa99e10d 59 minutes ago 347 MB srv.world/iproute latest dfa2b401b86c 4 hours ago 346 MB srv.world/centos-httpd latest ff3843182253 8 hours ago 354 MB quay.io/centos/centos stream10 1ef274445e32 7 days ago 311 MB docker.io/moby/buildkit buildx-stable-1 a72f628fa83e 5 weeks ago 207 MB docker.io/library/mariadb latest 6722945a6940 2 months ago 412 MB docker.io/library/registry latest 282bd1664cf1 15 months ago 26 MB apiVersion: apps/v1 kind: Deployment metadata: name: nginx-pod labels: name: nginx-pod spec: replicas: 1 selector: matchLabels: app: nginx-pod template: metadata: labels: app: nginx-pod spec: containers: - name: nginx-pod image: centos-nginx ports: - name: web containerPort: 80 [Unit] Description=Web service pod After=local-fs.target [Kube] Yaml=/etc/containers/systemd/nginx-pod.yml PublishPort=80:80 [Service] Restart=always [Install] WantedBy=multi-user.target default.target systemctl daemon-reload [root@dlp ~]# systemctl start nginx-pod.service
|
Sponsored Link |
|