I'm stupid - volume management

Hi all,
Since couple of month, i’m trying to learn and use docker correctly. Not with the success I may hope. Often, it’s working, but not like I want.
This time, my project is OwnCloud (And I want to do it the right way)
I’m using the docker-compose file givent here: https://raw.githubusercontent.com/owncloud/docs/master/modules/admin_manual/examples/installation/docker/docker-compose.yml
and i did some modification. As I want to have all content in a separate volume “/mnt/ownclouddata”, i’m trying to modify the file to launch the dockers to use my dedicated data mount point

In the 3 images, a modified the config:
owncloud:
volumes:
- files:/mnt/ownclouddata/data
db:
volumes:
- mysql:/mnt/ownclouddata/mysql
- backup:/mnt/ownclouddata/backup
redis:
volumes:
- redis:/mnt/ownclouddata/redis

But docker always place file on the local /var/lib/docker/volumes/ced77204ef4c0486532091a44bef449e3d5148df2d522abe56aa44f309aab171/_data/files/

What I do not understant in the process ? Do I need to modify something else ? What ? Is it related to the first section of the .yml file ? (volumes: )

I realy like the concept of Docker, I try to learn/test, but never have the result as clean as I want

Thanks,

I realy hate when people make me look at external links to explain their case. I never look at those links.

Back to topic: docker behaves exactly like your configured it, doesn’t it?

You mapped an (implicitly) named volume, which is to be expected under /var/lib/docker/volumes/{volumename}/, into the container path /mnt/ownclouddata/{foldername}.

If you want to use bind mounts (which mounts a host folder of your choise into a container folder of your choise) instead of volumes, you need to provide a path, e.g. /data/container/ownclouddata/mysql:/mnt/ownclouddata/mysql (I have not checked if the container side of the mount is actualy correct).

since there is no sanity check whether the container folder is correct, make sure to use the right hand side of the mapping as provided in the docker-compose.yml or the dockerhub description.

Thanks for your reply.
I’m aware of the concept of allowing volume in docker to a “physical” folder on the local machine. I’m already did it in command like:
docker run -v /docker/path/:/local/path
But in this docker compose file, as I can understand, it seems to do not work like this, As I already mentionned, I create modified the volume part of the docker:

owncloud:
  volumes:
  - files:/mnt/ownclouddata/data

Maybe the problem is in the portion of the yml where i define volumes ??

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

So, here is the copy of all the .yml content (with the volume information I modified:

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:
      - ${HTTP_PORT}:8080
    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_MYSQL_UTF8MB4=true
      - OWNCLOUD_REDIS_ENABLED=true
      - OWNCLOUD_REDIS_HOST=redis
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - files:/mnt/ownclouddata/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
    healthcheck:
      test: ["CMD", "/usr/bin/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - mysql:/mnt/ownclouddata/mysql
      - backup:/mnt/ownclouddata/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:/mnt/ownclouddata/redis

Thanks,

I am not sure why your last response is only visible as email… but here we go:

What makes you think bind mounts would not work with docker-compose? If you would’ve tried them, you would’ve realized that they work.

A volume in a docker-compose file can be either a volume or a bind mount. Unless you run a multi-node swarm setup, using bind mounts usually is fine.

hummm, you lost me when you talked about “volume or a bind mount”

Honestly, I simply modified the .yml file with kind of personnal settings wanted. and … it worked, The application is working. But, not storing file where I want them. They are stored directly in the /var/lib/docker/volumes.
I thought that by defining my variable “- files:/mnt/ownclouddata/data” the docker would stoke my files in /mnt/ownclouddata/data. But it’s not the case.

Concretely, what am I doing wrong ? What I don’t understand ?

Let me take a snippet of your compose file which uses volumes:

You can chage it to bind mounts, which use a full path

...
  db:
    ...
    volumes:
    - /local/path/to/ownclouddata/mysql:/mnt/ownclouddata/mysql
    - /local/path/to/ownclouddata/backup:/mnt/ownclouddata/backup
    ...

Please take your time to understand the difference and actualy try it, before asking your next question.

A docker volume is managed by docker - either you need to learn how to configure it or use the default values. A bind mount on the hand is litterely mouting a host folder into a container folder.

Good luck!

Thanks again, but, with your answer, I understand (i think) i already knows the solution you gave me. But, the .yml file, given by the official support documentation, gives lines likes:

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

In this section, you declare the volume you will use. Am I right ?

They also have lines like:

    volumes:
      - files:/mnt/data

In this option, I belived docker is going to configure the volume named “files” in my local “/mnt/data” an the system is smart enough to know the internal path of “files” volume. (Correct or not ?)

The support/deploy page never mention the path used inside the docker.

I seriously believed this lines (- files:/mnt/data) was somethig like
for $FilesPath$ in docker, use “/mnt/data” on the host.

Personnaly, of the few things I know, my first idea would have been to use the option you mentionned. But as I don’t know the path used inside docker, I cannot. (or i’m not smart enough)

I was sure docker-compose and .yml was a formula you must insert your own spec/variable, apply them, and the rest is done but docker and the image.

I can understand that you can be desperate, but, i’m so confused

Your understanding is wrong: never, never ever change the right hand side [after the colon :] of a port or volume mapping, unless you know what you are doing. The same is true for the left hand side of environment variables. You can not simply make up stuff and expect it to work…

Please use the paths that are used in the original, unmodified docker-compose.yml instead of whatever you tried and use bind mounts for the left hand side of the mapping.

May I suggest that you exercise this excellent free self paced docker training to get a better understand on how docker works and how things are supposed to be done?