Docker creates folder instead of file on bind mount

Hi
I have the following problem:

I’d like to run this container:
sudo docker run -d -p 8080:80 -v /mnt/test:/app/public/conf.yml --name my-dashboard
–restart=always lissy93/dashy:2.1.2

/mnt/test/conf.yml, here the conf.yml is not created and is expected to be “copied” from container, right?
/app/public/conf.yml is already existing inside container.

Maybe important: I’m running this from a Linux container on proxmox, however have turned on nesting (container unpriviledged)

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting “/mnt/test” to rootfs at “/app/public/conf.yml”: mount /mnt/test:/app/public/conf.yml (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

When executing the command this error popps up and docker creates conf.yml as a folder instead of file.

Not right. A single file is never copied from a container and when you use bind mounts, that is just the same as using the “mount” command on Linux. You overwrite the destination with the source. If the source doesn’t exist, then Docker creates a file. Unless you you use --mount instead of -v which has a different syntax and can throw an error instead of creating anything automatically.

I recommend reading my tutorial about volumes if you want to understand what you need:

1 Like

Okay I see. Thanks a lot!