Podman : Generate Systemd unit file2025/01/21 |
It's possible to generate Systemd unit file and set auto-starting for containers. |
|
[1] | Configure container service by using 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] # any name ContainerName=centos-nginx # container image to be used Image=srv.world/centos-nginx # port PublishPort=80:80 [Service] Restart=always [Install] WantedBy=multi-user.target default.target systemctl daemon-reload [root@dlp ~]# systemctl start centos-nginx.service
|
[2] | Configure pod service by using Quadlet. |
[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 # create pod configuration file # format is the same as Kubernetes [root@dlp ~]# vi /etc/containers/systemd/nginx-pod.yml 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 |
|