Podman : コンテナーの自動起動の設定2024/11/06 |
|
Systemd ユニットファイルを生成して、システム起動時にコンテナーが自動起動できるよう設定します。 |
|
| [1] | Quadlet を使用したコンテナーサービスの設定です。 |
|
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.2.5-1729209600 64b1ac1938a3 13 minutes ago 758 kB srv.world/iproute latest 84acd2cc8c75 20 minutes ago 250 MB docker.io/library/root-web latest b38a153fb7b0 37 minutes ago 316 MB srv.world/fedora-nginx latest cb2e14e1465e About an hour ago 316 MB srv.world/fedora-httpd latest 4dfbd95b4ef6 About an hour ago 319 MB registry.fedoraproject.org/fedora latest 99519fcf3c1b 19 hours ago 163 MB docker.io/library/mariadb latest 4b8711c6c639 2 months ago 413 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 5.2.5-1729209600 64b1ac1938a3 15 minutes ago 758 kB srv.world/iproute latest 84acd2cc8c75 21 minutes ago 250 MB docker.io/library/root-web latest b38a153fb7b0 39 minutes ago 316 MB srv.world/fedora-nginx latest cb2e14e1465e About an hour ago 316 MB srv.world/fedora-httpd latest 4dfbd95b4ef6 About an hour ago 319 MB registry.fedoraproject.org/fedora latest 99519fcf3c1b 19 hours ago 163 MB docker.io/library/mariadb latest 4b8711c6c639 2 months ago 413 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 |
|
|