Docker-compose local directory mappings are ignored, docker volumes are used instead

Hi everyone, first time setting up owncloud, and I’m trying to do it using docker-compose. The YAML file that I’m using is the following:

version: "3"

services:
  owncloud:
    image: owncloud/server:latest
    container_name: owncloud_server
    restart: always
    ports:
      - 1234:8080
    depends_on:
      - mariadb
      - redis
    environment:
      - OWNCLOUD_DOMAIN=owncloud.mydomain.net
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=passwd
      - OWNCLOUD_DB_HOST=mariadb
      - OWNCLOUD_ADMIN_USERNAME=user-admin
      - OWNCLOUD_ADMIN_PASSWORD=passwd
      - OWNCLOUD_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    volumes:
      - /mnt/volume-nbg1-1/owncloud/files:/var/www/html/files
      - /mnt/volume-nbg1-1/owncloud/config:/var/www/html/config
      - /mnt/volume-nbg1-1/owncloud/apps:/var/www/html/apps
      - /mnt/volume-nbg1-1/owncloud/sessions:/var/www/html/sessions

  mariadb:
    image: mariadb:10.5
    container_name: owncloud_mariadb
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=passwd
      - MYSQL_USER=owncloud
      - MYSQL_PASSWORD=passwd
      - MYSQL_DATABASE=owncloud
    volumes:
      - /mnt/volume-nbg1-1/owncloud/mariadb:/var/lib/mysql

  redis:
    image: redis:6
    container_name: owncloud_redis
    restart: always
    volumes:
      - /mnt/volume-nbg1-1/owncloud/redis:/data

My issue is that although the Redis and MariaDB directories are created and filled correctly upon deployment, the owncloud mounted directories seem to be created correctly, but then a docker volume is also created inside /var/lib/docker/volumes/<random_seq>/_data and then the directories in it are the ones that get populated. The owncloud.log is empty, so I can’t get any hints from that. I’ve also tried changing the owner of the owncloud dir inside /mnt/volume-nbg1-1 to the docker user, but that didn’t change anything. Any ideas on what I’m doing wrong?

Hello,

The container is ignoring your bind mount and creates a docker volume instead because the target inside the container is wrong (see documentation).

The target within the container is /mnt/data while you try to manually bind mount to directories that are not used in the container setup. You just need a single bind mount to /mnt/data e.g. /mnt/volume-nbg1-1/owncloud/data:/mnt/data as the container is configured to place all relevant files there:

❯ docker exec -it dbb7f401ce8e ls -l /mnt/data
total 0
drwxr-xr-x. 2 www-data root   6 Apr 27 06:58 apps
drwxr-xr-x. 2 www-data root  82 Apr 27 06:58 config
drwxrwx---. 4 www-data root 132 Apr 27 07:00 files
drwxr-xr-x. 2 www-data root   6 Apr 27 06:58 sessions
1 Like

Thank you so much, I wouldn’t have imagined that it was such a simple mistake :stuck_out_tongue: This fixed it!

If you don’t mind me asking, do you have any idea why when I log in to the web UI, I get a “Directory “/” not found” warning but no logs in the owncloud.log file? Should I create a separate post?

Glad to help.

You might want to look into Directory "/" not found first.