Podman : Generate Systemd unit file2025/04/25 |
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.4.2-1743552000 44beb5bc0a3a 30 minutes ago 776 kB srv.world/iproute latest aa9549af2c42 2 hours ago 258 MB docker.io/library/root-web latest 6b8099ee8b9d 3 hours ago 325 MB srv.world/fedora-nginx latest ad26e76247bd 3 hours ago 325 MB srv.world/fedora-httpd latest 512d39041a55 3 hours ago 328 MB registry.fedoraproject.org/fedora latest e5bf03515e92 25 hours ago 166 MB docker.io/library/mariadb latest 9f3d79eba61e 2 months ago 334 MB [Unit] Description=Nginx container After=local-fs.target [Container] # any name ContainerName=fedora-nginx # container image to be used Image=srv.world/fedora-nginx # port PublishPort=80:80 [Service] Restart=always [Install] WantedBy=multi-user.target default.target systemctl daemon-reload [root@dlp ~]# systemctl start fedora-nginx.service
|
[2] | Configure pod service by using Quadlet. |
[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/podman-pause 5.4.2-1743552000 44beb5bc0a3a 31 minutes ago 776 kB srv.world/iproute latest aa9549af2c42 2 hours ago 258 MB docker.io/library/root-web latest 6b8099ee8b9d 3 hours ago 325 MB srv.world/fedora-nginx latest ad26e76247bd 3 hours ago 325 MB srv.world/fedora-httpd latest 512d39041a55 3 hours ago 328 MB registry.fedoraproject.org/fedora latest e5bf03515e92 25 hours ago 166 MB docker.io/library/mariadb latest 9f3d79eba61e 2 months ago 334 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: 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 |
|