0
0
Dockerdevops~5 mins

Volumes in Compose in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AInside the container's writable layer
BIn the container's memory
COn a remote cloud server
DIn Docker's managed storage area on the host
How do you declare a volume for a service in docker-compose.yml?
AIn the Dockerfile
BUnder the service's 'volumes:' key with volume_name:container_path
CUnder the 'services:' key only
DBy running a docker volume create command inside the container
What happens to data in a volume if the container is deleted?
AData is moved to a backup folder automatically
BData is deleted with the container
CData remains safe in the volume
DData is lost permanently
Which of these is NOT a benefit of using volumes?
AIncreasing container CPU speed
BSharing data between containers
CSeparating data from container lifecycle
DData persistence
What is a bind mount in Docker Compose?
AA direct link between a host folder and container folder
BA volume managed by Docker
CA network connection between containers
DA special type of container
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.