Skip to content

Volumes vs bind mounts

Select an icon to see what it is.

Step 4 of 6

A bind mount uses a path you choose

A bind mount names a host directory, such as /srv/web, instead of a volume. It hides whatever the image has at that path, so an empty /srv/web gives nginx an empty html directory. A new, empty named volume is different: Docker copies the image's files into it on first use.

$ docker run -d --name web -v /srv/web:/usr/share/nginx/html:ro nginx

POST /v1.45/containers/create?name=web

{
"Image": "nginx"
"HostConfig": {
"Binds": [
"/srv/web:/usr/share/nginx/html:ro"
]
}
}