My compose.yaml inside...
volumes:
db:
services:
db:
image: mariadb:10.6
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- db:/var/lib/mysql
secrets:
- mysql_root_password
- mysql_nextcloud_password
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_nextcloud_password
- MYSQL_DATABASE=
- MYSQL_USER=
nextcloud:
image: nextcloud
restart: always
ports:
- 8080:80
depends_on:
- db
links:
- db
volumes:
- /var/www/html:/var/www/html
- /srv/data:/srv/data
secrets:
- mysql_nextcloud_password
environment:
- MYSQL_PASSWORD_FILE=/run/secrets/mysql_nextcloud_password
- MYSQL_DATABASE=
- MYSQL_USER=
- MYSQL_HOST=db
secrets:
mysql_root_password:
file: ...
mysql_nextcloud_password:
file: ...
If you use the links:
element in the nextcloud
service, the services listed there will be available using their hostnames. On the Nextcloud setup screen, choose mysql as the database engine, use db
as the database host, and enter matching values into the other fields.