Podman : Generate Systemd unit file2023/11/16 |
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 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] # 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 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 # 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 |