Open-Source Wikis

/

Moby

/

Primitives

/

Volume and Mount

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. --mount and the legacy -v syntaxes both produce the same internal struct.

Wire types

In api/types/volume/:

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

  • Volumes for the full subsystem.
  • Container for how mounts attach to a container.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Volume and Mount – Moby wiki | Factory