Docker icon

Docker

Manage Docker containers, images, networks, volumes, and daemon metadata with Unix socket, TCP, TLS, or SSH connections

Volume → Create

AI-generated

Summary

Create a Docker volume with a given name, driver, optional labels and driver options, and an optional advanced JSON payload.

Inputs

  • volumeName (required) — Volume name or ID
  • volumeDriver — Volume driver to use (default: local)
  • volumeLabels — Labels to attach to the volume; each label has a Name and a Value
  • volumeDriverOptions — Options for the volume driver; each option has a Name and a Value
  • volumeAdvancedJson — Advanced JSON to override the structured volume create payload

Output shape

a volume object

Contains fields like Id, Name, Driver, Labels, and any driver‑specific attributes; may include warnings if unsupported options are provided

Examples

Example 1: Create a named volume called 'my-data' using the default driver

volumeName: 'my-data', volumeDriver: 'local'

Example 2: Create a volume with a custom driver and options

volumeName: 'backup', volumeDriver: 'rexray', volumeDriverOptions: [{name: 'size', value: '10GB'}]

Example 3: Create a volume with labels and advanced JSON

volumeName: 'logs', volumeLabels: [{name: 'Env', value: 'prod'}], volumeAdvancedJson: '{"AutoRemove": false}'

Links

Discussion