Podman : Generate Systemd unit file |
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-1753478586 ddf2e42fec3b 19 minutes ago 737 kB docker.io/library/root-web latest 3cc41f7733a0 25 minutes ago 157 MB srv.world/iproute latest 77debccd9811 36 minutes ago 156 MB srv.world/debian-nginx latest 33b7b5b10b13 About an hour ago 157 MB srv.world/debian-apache2 latest a0aca892bf29 About an hour ago 234 MB docker.io/library/debian latest 047bd8d81940 11 days ago 124 MB docker.io/library/mariadb latest 300929c28ab7 13 days ago 336 MB docker.io/moby/buildkit buildx-stable-1 44f5d48d5c6c 7 weeks ago 219 MB [Unit] Description=Nginx container After=local-fs.target [Container] # any name ContainerName=debian-nginx # container image to be used Image=srv.world/debian-nginx # port PublishPort=80:80 [Service] Restart=always [Install] WantedBy=multi-user.target default.target systemctl daemon-reload root@dlp:~# systemctl start debian-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-1753478586 ddf2e42fec3b 20 minutes ago 737 kB docker.io/library/root-web latest 3cc41f7733a0 26 minutes ago 157 MB srv.world/iproute latest 77debccd9811 37 minutes ago 156 MB srv.world/debian-nginx latest 33b7b5b10b13 About an hour ago 157 MB srv.world/debian-apache2 latest a0aca892bf29 About an hour ago 234 MB docker.io/library/debian latest 047bd8d81940 11 days ago 124 MB docker.io/library/mariadb latest 300929c28ab7 13 days ago 336 MB docker.io/moby/buildkit buildx-stable-1 44f5d48d5c6c 7 weeks ago 219 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: debian-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 podman pod ls POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS d6d95a44c29b nginx-pod-pod Running 6 seconds ago 223ba85b3446 2 |
No comments:
Post a Comment