Docker
/Intermediate
Compose Volumes
Definition
The declarative method for defining persistent Docker volumes at the bottom of a `docker-compose.yml` file, allowing multiple services to mount and share the same data.
Explain Like I'm New
Telling the conductor to prepare the external hard drives before starting the orchestra.
Real World Example
You define a top-level `volumes: { db_data: {} }` block in the YAML. Then, inside the database service, you map `db_data:/var/lib/mysql`. When you run `docker-compose down`, the containers are destroyed, but Compose intelligently preserves the `db_data` volume on the hard drive.
Common Use Cases
- •Data persistence
- •Multi-service data sharing
Interview Questions
basic
- If you run `docker-compose down`, does it automatically delete the Compose Volumes you created?
intermediate
- How do you completely destroy the entire app, INCLUDING the persistent database volumes?