Error with permissions for mariadb directory after running docker-compose

I’m following the steps in: HowTo: Ubuntu + Docker + Nextcloud + Talk + Collabora

I’m at the part where I added smb support, 5.4. Prior to this everything is fine, but trying to rebuild a custom image I get the following error after updating my dockerfile:

$ docker-compose up --build (or $ docker-compose build --pull)
Building nextcloud
Traceback (most recent call last):
File “bin/docker-compose”, line 3, in
File “compose/cli/main.py”, line 67, in main
File “compose/cli/main.py”, line 126, in perform_command
File “compose/cli/main.py”, line 1070, in up
File “compose/cli/main.py”, line 1066, in up
File “compose/project.py”, line 615, in up
File “compose/service.py”, line 346, in ensure_image_exists
File “compose/service.py”, line 1125, in build
File “docker/api/build.py”, line 160, in build
File “docker/utils/build.py”, line 30, in tar
File “docker/utils/build.py”, line 49, in exclude_paths
File “docker/utils/build.py”, line 214, in rec_walk
File “docker/utils/build.py”, line 214, in rec_walk
File “docker/utils/build.py”, line 184, in rec_walk
PermissionError: [Errno 13] Permission denied: ‘/home/username/nextcloud/mariadb/nextcloud’
[29500] Failed to execute script docker-compose

Currently mariadb folder owner: systemd Core Dumper, Group: root and /mariadb/nextcloud/ is unreadable, and owner/group: systemd Core Dumper. Every single item in /mariadb directory has a red x icon on it.

Any thoughts on what I need to change? I haven’t changed permissions on mariadb yet, I tried earlier setting it to www-data but it didn’t change anything, so I deleted all the docker-compose and docker images and the data html mariadb folders in /nextcloud and rebuilt.

Here is my docker-compose.yml (there is proper indentation in my actual file):

version: ‘3.7’

networks:
nextcloud:

services:
nextcloud:
image: nextcloud:custom_smb
build: .
container_name: nextcloud
networks:
- nextcloud
ports:
- “127.0.0.1:8080:80”
volumes:
- ${NEXTCLOUD_ROOT}/html:/var/www/html
- ${NEXTCLOUD_ROOT}/data:/srv/nextcloud/data
extra_hosts:
- “${NEXTCLOUD_FQDN}:${NEXTCLOUD_IPADDRESS}”
- “${COLLABORA_FQDN}:${NEXTCLOUD_IPADDRESS}”
depends_on:
- mariadb
- redis
environment:
- NEXTCLOUD_TRUSTED_DOMAINS=’${NEXTCLOUD_FQDN}’
- NEXTCLOUD_DATA_DIR=/srv/nextcloud/data
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_HOST=nextcloud-mariadb
- REDIS_HOST=nextcloud-redis
restart: unless-stopped

mariadb:
image: mariadb
container_name: nextcloud-mariadb
restart: unless-stopped
volumes:
- ${NEXTCLOUD_ROOT}/mariadb:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
networks:
- nextcloud

redis:
image: redis
container_name: nextcloud-redis
networks:
- nextcloud
restart: unless-stopped

coturn:
image: instrumentisto/coturn
container_name: nextcloud-coturn
restart: unless-stopped
ports:
- “3478:3478/tcp”
- “3478:3478/udp”
networks:
- nextcloud
command:
- -n
- --log-file=stdout
- --min-port=49160
- --max-port=49200
- --realm=${NEXTCLOUD_FQDN}
- --use-auth-secret
- --static-auth-secret=${COTURN_SECRET}

collabora:
image: collabora/code
container_name: nextcloud-collabora
restart: unless-stopped
networks:
- nextcloud
ports:
- “127.0.0.1:9980:9980”
extra_hosts:
- “${NEXTCLOUD_FQDN}:${NEXTCLOUD_IPADDRESS}”
- “${COLLABORA_FQDN}:${NEXTCLOUD_IPADDRESS}”
environment:
- ‘domain=${NEXTCLOUD_FQDN}’
- ‘dictionaries=en’
cap_add:
- MKNOD
tty: true

Red x? What is your OS?

I looked at the permissions on one of my installations. The mariadb folder is owned by user mysql (may be presented as numerical ID 999) and group root, and the contents under that are mysql:mysql.

Under no circumstances would I recommend changing permissions on any of these folders mapped by Docker because it will most likely cause permission errors within the containers.

If this is a new setup with no data yet, you may find it easier to start over. You can run docker-compose down and then remove the mariadb folder. When you start it again it should create a new one. You may have to do this with the nextcloud folder as well depending on exactly where you are in the process.