0
0
Dockerdevops~5 mins

Sharing volumes between containers in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Docker volume?
A Docker volume is a storage area managed by Docker that containers can use to save and share data persistently outside the container's writable layer.
Click to reveal answer
beginner
How do you share data between two Docker containers using volumes?
You create a Docker volume and mount it into both containers at the desired path. This way, both containers can read and write to the same data location.
Click to reveal answer
beginner
What is the command to create a Docker volume named 'shared-data'?
docker volume create shared-data
Click to reveal answer
intermediate
How do you run two containers sharing the same volume 'shared-data' at path '/app/data'?
docker run -d --name container1 -v shared-data:/app/data image1 docker run -d --name container2 -v shared-data:/app/data image2
Click to reveal answer
beginner
Why is sharing volumes between containers useful?
It allows containers to share files and data easily, such as logs, configuration files, or databases, without copying data between containers or rebuilding images.
Click to reveal answer
Which Docker command creates a volume named 'data-vol'?
Adocker volume create data-vol
Bdocker create volume data-vol
Cdocker volume new data-vol
Ddocker volume add data-vol
How do you mount a volume named 'shared-vol' to '/data' inside a container?
Adocker run -v /data:shared-vol image
Bdocker run --mount shared-vol:/data image
Cdocker run --volume /data:shared-vol image
Ddocker run -v shared-vol:/data image
What happens if two containers share the same Docker volume?
AThey cannot access the volume simultaneously.
BThey share the same data stored in the volume.
CEach container gets a copy of the volume data.
DThe volume is deleted after the first container stops.
Which of these is NOT a benefit of sharing volumes between containers?
APersistent data storage
BData sharing between containers
CAutomatic container networking
DAvoiding data duplication
To share a volume between containers, you must:
ACreate a volume and mount it in both containers
BCopy files manually between containers
CUse the same image for both containers
DRun containers on the same host only
Explain how to share data between two Docker containers using volumes.
Think about creating a common storage space both containers can use.
You got /3 concepts.
    Describe the benefits of using Docker volumes to share data between containers.
    Consider why sharing data directly is better than copying files.
    You got /4 concepts.