Skip to content

Volumes vs bind mounts

Select an icon to see what it is.

Step 2 of 6

The container asks to mount it

The create request lists the mount in HostConfig.Binds as name:path. dockerd resolves the name to the volume's directory on the host. The data will live there, outside the container's writable layer.

$ docker run -d --name db -e POSTGRES_PASSWORD=example -v pgdata:/var/lib/postgresql/data postgres:17

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

{
"Image": "postgres:17"
"HostConfig": {
"Binds": [
"pgdata:/var/lib/postgresql/data"
]
}
}