Skip to content
Latchkey

docker volume Command Reference

Manage named volumes.

docker volume groups the volume subcommands: create, ls, inspect, rm, and prune. Named volumes persist data outside a container lifecycle and are the recommended way to share or cache data between containers in a pipeline.

Common subcommands

  • docker volume create NAME - create a named volume
  • docker volume ls - list volumes (-q for names only)
  • docker volume inspect NAME - show volume metadata as JSON
  • docker volume rm NAME - remove a volume
  • docker volume prune -f - remove all unused volumes

Example

shell
docker volume create pgdata
docker run -d --name db -v pgdata:/var/lib/postgresql/data postgres:16
docker volume prune -f

In CI

Use a named volume to persist a database between steps within a job, or to share a cache directory between containers. docker volume prune -f reclaims unused volumes on a persistent runner; a volume in use by any container is skipped.

Key takeaways

  • Named volumes outlive containers and are the way to share or persist data.
  • docker volume prune -f reclaims unused volumes on long-lived runners.
  • A volume bound to any container is not pruned.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →