I’m trying to run the this docker-compose.yml file with the named volume for nextcloud. What I expect to see is docker creating the folders for nextcloud at /media/onetouch5t/pi4/data/nextcloud/html and …/db, but I’m not sure where I did it wrong making it giving the following error message:
Error response from daemon: failed to populate volume: error while mounting volume '/var/lib/docker/volumes/nextcloud-database/_data': failed to mount local volume: mount /media/onetouch5t/pi4/data/nextcloud/db:/var/lib/docker/volumes/nextcloud-database/_data, flags: 0x1000: no such file or directory
If I don’t use the named volume everything will be working just fine.
Can someone tell me what’s wrong with it?
Doesn’t seem to matter if it is ext4 or ntfs actually.
I think the problem is more about me using this IOTstack. They might have do something to how docker interprets relative path and absolute path. For instance, when I ask docker to put my portainer container volume at ./volumes/portainer-ce, it actually put it inside of ~/IOTstack/volumes/portainer-ce. I wonder if they could do something to the named volume and change the way it is being used.
Sorry for the late reply, and thanks for helping out.
I tried today and now the error code becomes this:
Error response from daemon: failed to populate volume: error while mounting volume '/var/lib/docker/volumes/Vol_nextcloud_db/_data': failed to mount local volume: mount /media/onetouch5t/pi4/data/nextcloud/db:/var/lib/docker/volumes/Vol_nextcloud_db/_data, flags: 0x1000: no such file or directory
Does the folders have to exist before I start docker compose?
It seems like if I create an empty folder it will run fine
Yes, when you use named volumes with custom source path, the volume source has to exist. The folder created by Docker will be just a symlink to the original folder. Also when you run docker compose down -v which would remove named volumes as well, only the fodler with the symlink in the docker data root will be removed, but Docker will not touch your original folder.
Is there a way I can store the path somewhere in docker compose file (not another .env file or Dockerfile) and use it all the time including let docker create the html folder if it doesn’t exist?
The extensions part sort of meet my needs if I can store /media/…/html into a variable and use it all the time, but I’m not sure how to use it correctly in this case.
Maybe this is another separated question. I can open another topic if you like.
You can use extensions, but that could also overcomplicate things and it will not help you to create folders.
You will have to create the folder before running the compose project and although so you can have a script that prepares everything and executes the compose project. I do the same in my projects. I also use a template system to generate the compose file instead of extensions.
If you want to discuss extensions (or templating) further, I would indeed recommend a new topic.