Docker Community Forums

Share and learn in the Docker community.

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:
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:
- files:/mnt/ownclouddata/data
- mysql:/mnt/ownclouddata/mysql
- backup:/mnt/ownclouddata/backup
- 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


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.

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

    - /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:

driver: local
driver: local
driver: local
driver: local

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

They also have lines like:

  - 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?