Podman : Generate Systemd unit file2026/05/07 |
|
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/root_web latest 2b7dad1fb609 36 minutes ago 153 MB srv.world/iproute latest 761cdbcf586d 53 minutes ago 157 MB srv.world/ubuntu-nginx latest 4bb5563726cd 18 hours ago 153 MB srv.world/ubuntu-apache2 latest 53b7e6d878bc 18 hours ago 231 MB dlp.srv.world:5000/ubuntu my-registry 30ba44506a6d 2 weeks ago 111 MB docker.io/library/ubuntu latest 30ba44506a6d 2 weeks ago 111 MB docker.io/library/mariadb latest 8431e30f98d8 3 weeks ago 341 MB [Unit] Description=Nginx container After=local-fs.target [Container] # any name ContainerName=ubuntu-nginx # container image to be used Image=srv.world/ubuntu-nginx # port PublishPort=80:80 [Service] Restart=always [Install] WantedBy=multi-user.target default.target # disable apparmor profiles below root@dlp:~# apparmor_parser -R /etc/apparmor.d/podman root@dlp:~# apparmor_parser -R /etc/apparmor.d/crun root@dlp:~# ln -s /etc/apparmor.d/podman /etc/apparmor.d/disable/ root@dlp:~# ln -s /etc/apparmor.d/crun /etc/apparmor.d/disable/
systemctl daemon-reload root@dlp:~# systemctl start ubuntu-nginx.service
|
| [2] | Configure pod service by using Quadlet. |
|
root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/root_web latest 2b7dad1fb609 38 minutes ago 153 MB srv.world/iproute latest 761cdbcf586d 55 minutes ago 157 MB srv.world/ubuntu-nginx latest 4bb5563726cd 18 hours ago 153 MB srv.world/ubuntu-apache2 latest 53b7e6d878bc 18 hours ago 231 MB dlp.srv.world:5000/ubuntu my-registry 30ba44506a6d 2 weeks ago 111 MB docker.io/library/ubuntu latest 30ba44506a6d 2 weeks ago 111 MB docker.io/library/mariadb latest 8431e30f98d8 3 weeks ago 341 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: ubuntu-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 108f96966913 nginx-pod-pod Running 3 seconds ago 21d8f8641742 2 a551a0550afa pod_root Created 38 minutes ago 0 |
| Sponsored Link |
|
|