Podman : コンテナーの自動起動の設定2023/11/16 |
Systemd ユニットファイルを生成して、システム起動時にコンテナーが自動起動できるよう設定します。
|
|
[1] | Quadlet を使用したコンテナーサービスの設定です。 |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 4.7.2-1698762721 cb1af0765d22 12 minutes ago 1.14 MB srv.world/iproute latest b2ff20987c53 20 minutes ago 417 MB localhost/root_web latest e1fc63ab5511 47 minutes ago 447 MB srv.world/fedora-nginx latest 6a43f18a8fc3 About an hour ago 447 MB srv.world/fedora-httpd latest 43a608e50bc8 2 hours ago 459 MB registry.fedoraproject.org/fedora latest ec546109f822 8 days ago 183 MB dlp.srv.world:5000/fedora my-registry ec546109f822 8 days ago 183 MB docker.io/library/mariadb latest f35870862d64 4 weeks ago 410 MB [Unit] Description=Nginx container After=local-fs.target [Container] # 任意の名称 ContainerName=fedora-nginx # 使用するコンテナーイメージ Image=srv.world/fedora-nginx # ポート PublishPort=80:80 [Service] Restart=always [Install] WantedBy=multi-user.target default.target systemctl daemon-reload [root@dlp ~]# systemctl start fedora-nginx.service
|
[2] | Quadlet を使用した Pod サービスの設定です。 |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 4.7.2-1698762721 cb1af0765d22 12 minutes ago 1.14 MB srv.world/iproute latest b2ff20987c53 20 minutes ago 417 MB localhost/root_web latest e1fc63ab5511 47 minutes ago 447 MB srv.world/fedora-nginx latest 6a43f18a8fc3 About an hour ago 447 MB srv.world/fedora-httpd latest 43a608e50bc8 2 hours ago 459 MB registry.fedoraproject.org/fedora latest ec546109f822 8 days ago 183 MB dlp.srv.world:5000/fedora my-registry ec546109f822 8 days ago 183 MB docker.io/library/mariadb latest f35870862d64 4 weeks ago 410 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: fedora-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 |