2

I followed this guide to install owncloud server on my VPS, it works. However there is an issue when I was trying to mount the file volume to host server. Below is the docker-compose.yml file I use. If I run the docker image with the yml file directly, I can't find there is any owncloud data under the directory /mnt/data of my VPS even I created /mnt/data manually.

version: '2.1'

volumes:
  files:
    driver: local
  mysql:
    driver: local
  backup:
    driver: local
  redis:
    driver: local

services:
  owncloud:
    image: owncloud/server:${OWNCLOUD_VERSION}
    restart: always
    ports:
      - ${HTTPS_PORT}:443
      - ${HTTP_PORT}:80
    depends_on:
      - db
      - redis
    environment:
      - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
      - OWNCLOUD_DB_TYPE=mysql
      - OWNCLOUD_DB_NAME=owncloud
      - OWNCLOUD_DB_USERNAME=owncloud
      - OWNCLOUD_DB_PASSWORD=owncloud
      - OWNCLOUD_DB_HOST=db
      - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
      - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - OWNCLOUD_UTF8MB4_ENABLED=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - files:/mnt/data

  db:
    image: webhippie/mariadb:latest
    restart: always
    environment:
      - MARIADB_ROOT_PASSWORD=owncloud
      - MARIADB_USERNAME=owncloud
      - MARIADB_PASSWORD=owncloud
      - MARIADB_DATABASE=owncloud
      - MARIADB_MAX_ALLOWED_PACKET=128M
      - MARIADB_INNODB_LOG_FILE_SIZE=64M
      - MARIADB_INNODB_LARGE_PREFIX=ON
      - MARIADB_INNODB_FILE_FORMAT=Barracuda
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - mysql:/var/lib/mysql
      - backup:/var/lib/backup

  redis:
    image: webhippie/redis:latest
    restart: always
    environment:
      - REDIS_DATABASES=1
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - redis:/var/lib/redis

So I tried modifying line files:/mnt/data to files:/mnt/data:/mnt/data, then it prompted me with following error.

ERROR: for ownclouddockerserver_owncloud_1  Cannot create container for service owncloud: invalid bind mount spec "ownclouddockerserver_files:/mnt/data:/mnt/data": invalid mode: /mnt/data

ERROR: for owncloud  Cannot create container for service owncloud: invalid bind mount spec "ownclouddockerserver_files:/mnt/data:/mnt/data": invalid mode: /mnt/data

Can anyone help me out to figure out the right way of mounting external directory to container's? Much appreciated.

kenshinji
  • 2,021
  • 4
  • 25
  • 39
  • Have you tried putting the full path in ? e.g. /my/external/directory:/mnt/data Also are you running on Windows or Linux ? You can get mount issues if you are running on Windows 7 inside virtual box. It only likes mounts within certain user directories from memory. – PaulNUK Aug 10 '18 at 10:21
  • try this answer first, https://stackoverflow.com/questions/41299514/docker-compose-define-mount-for-bind-mount-and-managed-mount – user2262504 Aug 10 '18 at 10:34
  • @PaulNUK thank you for your suggestions. yes, full path, and from the path I think you've already know I'm running on LInux. – kenshinji Aug 11 '18 at 15:58
  • Did anyone actually have an accepted answer for this ? – MB. Jan 25 '19 at 20:45

1 Answers1

0

The /mnt/data directory exists only inside your docker container. It is mapped to a generated (virtual) drive called files.

In order to map the /mnt/data directory to a local directory, you use: /my/local/directory:/mnt/data

bguiz
  • 27,371
  • 47
  • 154
  • 243