moby/moby
Volume and Mount
Definitions
- Volume — a named, daemon-managed entity backed by a driver. Default driver is
local; plugins add others. - Mount — a per-container request: bind, volume, or tmpfs.
--mountand the legacy-vsyntaxes both produce the same internal struct.
Wire types
| Type | Purpose |
|---|---|
Volume |
docker volume inspect payload. |
CreateOptions |
POST /volumes/create body. |
ListResponse |
GET /volumes. |
ClusterVolume* |
CSI volumes managed by swarm. |
In api/types/mount/:
| Type | Purpose |
|---|---|
Mount |
--mount spec; covers bind, volume, tmpfs, npipe, image, cluster. |
BindOptions, VolumeOptions, TmpfsOptions, ImageOptions |
Per-type extras. |
Internal types
| Object | File |
|---|---|
Volume |
daemon/volume/volume.go |
MountPoint |
daemon/volume/mounts/mounts.go |
Driver |
daemon/volume/volume.go |
VolumesService |
daemon/volume/service/service.go |
Mount resolution
Parsing happens in daemon/volume/mounts/parser.go (Linux) and friends. The result is a MountPoint per request, with type, source path, destination, mode, and driver options. At container start, the daemon walks MountPoints:
- Bind mounts → check the host path exists, optionally chowning for userns.
- Named volumes → call
Driver.Get(name)to obtain a host path. - Tmpfs → just record the size/mode for the OCI spec.
The list is then translated into OCI mount spec entries by daemon/oci_linux.go.
Refcounting
The volumes service tracks how many containers reference a given volume; docker volume rm fails on a volume in use. Implementation in daemon/volume/service/.
See also
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.