Docker - Bind mount

Card Puncher Data Processing


bind mount is type of mount. It's one of the three way on how you can persist data from a container. See Docker - Data Persistence



The file or directory is referenced by its full or relative path on the host machine. The file or directory does not need to exist on the Docker host already.


docker run -d \
  -it \
  --name devtest \
  --mount type=bind,source="$(pwd)"/target,target=/app \

-v or –volume

The -v or --volume options when mounting a bind mount, consists of three fields, separated by colon characters :

  • the first field is the path to the file or directory on the host machine ( for a volume mount, it would be the volume name)
  • the second field is the path where the file or directory is mounted in the container.
  • the third field is optional, and is a comma-separated list of options, such as ro, consistent, delegated, cached, z, and Z.


  • bash
docker run -it --rm -v /c/tmp:/pathInContainer/  ubuntu bash
  • dos
docker run ^
    --name containerName ^
    -v %cd%:/var/www/html/ ^


docker inspect containerName
"Mounts": [
		"Type": "bind",
		"Source": "/host_mnt/c/code/bdm",
		"Destination": "/ansible/playbooks",
		"Mode": "",
		"RW": true,
		"Propagation": "rprivate"

This shows that:

  • the type of mount,
  • the source directory
  • the destination directory
  • the mode for optional options Example:
  • the mount is read-write. Not Read only
  • the propagation is set to rprivate. The propagation settings control whether a mount on /tmp/a would also be available on /mnt/a. See propagation


Mount path must be absolute

I got this error using MGINX. Below is a workaround

SOURCE_MOUNT_POINT=$(cygpath -u $(readlink -f ../myRelativePath))

# then  mount
docker run \
    --mount type=bind,source=/$SOURCE_MOUNT_POINT,target=/var/www/html \

Error while creating mount source path: file exists

Error response from daemon: error while creating mount source path '/host_mnt/d/dokuwiki': mkdir /host_mnt/d: file exists

Just restart docker

Mount denied: The source path doesn't exist and is not known to Docker

On Windows 10

docker: Error response from daemon: Mount denied:
The source path "D:/tmp"
doesn't exist and is not known to Docker.
See 'docker run --help'.

Solution: The credentials for the mount have expired, reset them

Docker Shared Drive New Credentials

Documentation / Reference

Discover More
Card Puncher Data Processing
Docker - Data Persistence

mount a file or directory of the host into a container. volume: mount a file or directory of the host machine into a container located at /var/lib/docker/volumes/ : mount a file or directory of the...
Toolbox Componentns
Docker - Installation for Windows 7 (Docker Toolbox)

How I have installed and configured Docker in my Windows 7 laptop. The software for windows 7 is called Docker Toolbox. Before version Windows 10: Toolbox:...
Card Puncher Data Processing
Docker - Mount

in docker The type can be: bind, volume, or tmpfs tmpfs and looks at the section Mounts where: type can be : or
Firewall Docker Trusted Adapter
Docker - Shared Drive (Windows)

shared drive For windows Shared drives require port 445 to be open between the host machine and the virtual machine that runs Linux containers. Allow connections to on port 445 (the...
Card Puncher Data Processing
Docker - Volume Mount

in Docker. A volume is one type of mount in docker. Volumes are one of the way of persisting data between container execution. They are file store on the host where you can persist data generated by...
Card Puncher Data Processing
How to run a docker image with example to create a container?

The run command creates a container from an image on the virtual host and calls the entrypoint script. start To generate this message, Docker took the following steps: The Docker client contacted...
Jenkins Unlock
Jenkins - Docker Installation

Jenkins installation on Docker Create an container and run it from the Community edition image /var/run/docker.sock on Windows mounting JENKINS_HOME to a local directory (in our example to...
Scale Counter Graph
Prometheus Server Docker Installation on Windows

Step by step to start a Prometheus Server instance with a Docker container and a bind mount. Create a prometheus.yml file. Example: In the same directory than the created configuration file...

Share this page:
Follow us:
Task Runner