Home > database >  Create and bind mount file in Docker
Create and bind mount file in Docker

Time:06-16

The Docker documentation about bind mounts states that:

The file or directory does not need to exist on the Docker host already. It is created on demand if it does not yet exist.

This is true for folders: if I bind mount as:

docker run -v $PWD/mydir:/mydir image:version

then the mydir folder is created and bind mounted in the container. But I cannot find the syntax for doing the same thing for a file either at the above linked page nor anywhere else.

CodePudding user response:

The documentation is inconsistent. There's an open issue on it: https://github.com/docker/docker.github.io/issues/10133

Docker always creates a directory if the host path doesn't exist. Or fails if you use the --mount syntax.

  • Related