volume

Storage managed by Docker that lives outside any container, so data survives when the container is removed.

In more detail

A named volume such as pgdata is created by Docker in its own storage area and mounted into a container at a path you choose, for example /var/lib/postgresql/data. Remove and recreate the container and the data is still there. Volumes bypass the union filesystem, so they are also faster for heavy writes. Delete them deliberately, because docker compose down -v and docker volume rm destroy the data.

Example

docker run -d -v pgdata:/var/lib/postgresql/data postgres:17

Related terms

Taught in

References

Certification courses