DELAPARRA
Index
Color
NL
Category: Docker

volumes (compose)

Explained by Updated

What is volumes (compose)?

volumes (compose): Declares named volumes and mounts them into services for persistent data that outlives container restarts. In Docker Compose, the top-level volumes section declares named volumes, and services mount them, as in db-data:/var/lib/postgresql/data. Named volumes keep data when containers are stopped, removed or recreated. That is essential for databases in development. Without a volume, docker compose down and up would give you an empty database every time.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about volumes (compose)

What should you keep in mind with volumes (compose)?

Named volumes are managed by Docker and listed with docker volume ls. docker compose down -v removes them together with the containers, which is handy for a clean start and dangerous when you did not mean it. For code, use bind mounts to your project folder instead, so edits appear immediately. Back up important volumes, for example with a database dump, because they live only on that one machine.

What does an example of volumes (compose) look like?

services: db: volumes: - db-data:/var/lib/postgresql/data volumes: db-data: {}

At a glance

CategoryDocker
Explained by
Updated

More Docker terms

All terms starting with V

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.