Recall & Review
beginner
What is a volume in Docker Compose?
A volume is a storage area outside the container's writable layer. It keeps data safe even if the container is deleted or recreated.
Click to reveal answer
beginner
How do you define a named volume in a docker-compose.yml file?
You define it under the 'volumes:' key at the bottom of the file, like this:<br>
volumes: mydata:
Click to reveal answer
intermediate
What is the difference between a bind mount and a volume in Docker Compose?
A bind mount links a host folder directly to the container, while a volume is managed by Docker and stored in Docker's storage area.
Click to reveal answer
beginner
How do you attach a volume to a service in docker-compose.yml?
Under the service, use the 'volumes:' key and specify the volume name and container path, like:<br>
volumes: - mydata:/app/data
Click to reveal answer
beginner
Why use volumes in Docker Compose?
Volumes keep data persistent, share data between containers, and separate data from container lifecycle.
Click to reveal answer
Where are Docker volumes stored by default?
✗ Incorrect
Docker volumes are stored in a special area on the host managed by Docker, separate from the container's writable layer.
How do you declare a volume for a service in docker-compose.yml?
✗ Incorrect
Volumes are declared under the service's 'volumes:' key in docker-compose.yml using the format volume_name:container_path.
What happens to data in a volume if the container is deleted?
✗ Incorrect
Volumes keep data safe even if the container is deleted or recreated.
Which of these is NOT a benefit of using volumes?
✗ Incorrect
Volumes help with data persistence and sharing but do not affect container CPU speed.
What is a bind mount in Docker Compose?
✗ Incorrect
A bind mount links a host folder directly to a container folder.
Explain how to define and use a volume in a docker-compose.yml file.
Think about where volumes are declared and how services use them.
You got /3 concepts.
Describe the benefits of using volumes in Docker Compose.
Why do we want data to live outside containers?
You got /3 concepts.