Docker Community Forums

Share and learn in the Docker community.

Docker-compose volume tries to create the source dir


I am trying to start a docker container using docker-compose.

Surprizingly, it tries to create the source volume dir using mkdir??

i have the following in the docker-compose.yml config:

- /media/source:/media/nextcloud

Cannot start service app: error while creating mount source path ‘/media/source’: mkdir /media/source: file exists

If it tries to create the source dir, whats the point of using named volumes?

Or am i missing something?

What is a named volume for you?

Your snippet shows a bind-mount, which literally uses mount --bind {source} {target}.
please share the output of ls -l /media.

Here is my docker-compose.yml

version: ‘3’

image: nextcloud-client:latest
restart: unless-stopped
- /media/pi/data/sync:/media/nextcloud
- NC_PASS=abc

ls -l /media/pi/data

drwx------ 4 pi pi 4096 Jul 27 09:43 sync

There is no nextcloud-client:latest image on Dockerhub.

Your folder is owned by the user and group pi with permissions only set for this user. How do you expect the NC Container to write in this folder?

i created my own image from Dockerfile from this repo: juanitomint/nextcloud-client

Let me explain what i am doing:
i need to sync encfs encrypted volume to nextcloud.
i use encfs in the --reverse mode, where the ‘sync’ folder is the encrypted output of my files.

df -h output:
encfs 192G 138G 44G 76% /media/pi/data/sync

so the sync folder is actually an encfs volume.

When i start the nextcloud-client, it tries to create the /media/pi/data/sync path, which it should not in the first place, since the docker-compose.yml tells to mount the /media/pi/data/sync folder as ‘/media/nextcloud’ within the docker container, and not create the source dir.

Did you check the behavior on one of the common filesystems like ext4 or xfs?

I wouldn’t be surprised if capabilites of encfs are responsible for the behavior. There must be a reason why docker thinks the folder is not existing. Since the docker engine is always run as root, it should not suffer from a lack permissons (though, the process in the container will).

if you mean ‘what if i mount a normal folder’?

Ofcourse docker works just fine. But the error docker reports isnt sane either.
By saying that its trying to create a dir of a pre-existing source volume, is not a correct error being reported to the user.
Is there any way to debug it whats actually happening while trying to mount an encfs volume?

Thanks for the response.

I would suggest to raise an error on docker’s github project.