Add a user like podman
to your system and enable “auto start” for your user by enabling loginctl enable-linger podman
.
In /etc/containers/registries.conf
set unqualified-search-registries = [ "docker.io"]
.
As podman
create two folders /home/podman/compose
and /home/podman/storage
.
Add a systemd user service:
[podman@53c70r ~]$ cat /home/podman/.config/systemd/user/podman-compose@.service
[Unit]
Description=%i podman compose service
Wants=network.target
After=network-online.target
[Service]
Type=forking
TimeoutStartSec=infinity
TimeoutStopSec=70
Restart=on-failure
RemainAfterExit=true
WorkingDirectory=/home/podman/compose/%I
ExecStart=podman-compose up -d
ExecStop=podman-compose down
[Install]
WantedBy=default.target
Reload systemd: systemctl --user daemon-reload
.
Now put your docker-compose.yml
to e.g. /home/podman/compose/nextcloud/docker-compose.yml
.
For example (the :Z
flag only works for SELinux enforced systems):
[podman@53c70r ~]$ cat /home/podman/compose/nextcloud/docker-compose.yml
version: '3'
services:
db:
image: mariadb:10.5
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- /home/podman/storage/nextcloud/db:/var/lib/mysql:Z
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_PASSWORD=
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
dns: 127.0.0.53
cpus: 1
redis:
image: redis:alpine
restart: always
cpus: 1
app:
image: nextcloud:fpm-alpine
restart: always
volumes:
- /home/podman/storage/nextcloud/html:/var/www/html:z
- /home/podman/storage/nextcloud/php-fpm/www2.conf:/usr/local/etc/php-fpm.d/www2.conf:ro,Z
environment:
- MYSQL_HOST=db
- REDIS_HOST=redis
- MYSQL_PASSWORD=
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
depends_on:
- db
- redis
dns: 127.0.0.53
cpus: 1
web:
image: nginx:alpine
restart: always
ports:
- 127.0.0.1:10000:80
volumes:
- /home/podman/storage/nextcloud/nginx/nginx.conf:/etc/nginx/nginx.conf:ro,Z
- /home/podman/storage/nextcloud/html:/var/www/html:ro,z
depends_on:
- app
cpus: 1
dns: 127.0.0.53
cron:
image: nextcloud:fpm-alpine
restart: always
volumes:
- /home/podman/storage/nextcloud/html:/var/www/html:z
entrypoint: /cron.sh
depends_on:
- db
- redis
cpus: 1
dns: 127.0.0.53
Now you can simple enable and start your service with systemctl --user enable --now podman-compose@nextcloud
.