Skip to content
Latchkey

docker volume create: Create Named Volumes

Create a named volume for data that should outlive a container.

docker volume create makes a named volume managed by Docker. This page covers drivers, labels, and when a named volume beats a bind mount in CI.

What it does

docker volume create allocates a named volume in Docker storage area. Containers mount it with -v name:/path. Volumes persist independently of containers and are the preferred way to keep stateful data.

Common usage

Terminal
docker volume create pgdata
docker run -d -v pgdata:/var/lib/postgresql/data postgres:16
docker volume create --label ci=true cache

Common errors in CI

Creating a volume that already exists is idempotent and not an error. A common CI mistake is expecting a named volume to be empty when reused across jobs on a persistent runner - it retains data; recreate it or use docker volume rm between runs. For per-job ephemeral data, prefer --rm containers with anonymous volumes or tmpfs.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →