Challenge - 5 Problems
Volume Sharing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of volume sharing with named volume
What is the output of the following commands when sharing a named volume between two containers?
Docker
docker volume create shared_data docker run -d --name writer -v shared_data:/data busybox sh -c "echo 'hello' > /data/greeting.txt && sleep 300" docker run --rm -v shared_data:/data busybox cat /data/greeting.txt
Attempts:
2 left
💡 Hint
Think about how named volumes persist data and are shared between containers.
✗ Incorrect
The named volume 'shared_data' is created and mounted in both containers. The first container writes 'hello' with a newline to /data/greeting.txt. The second container reads the file and outputs 'hello' with a newline.
❓ Configuration
intermediate2:00remaining
Correct docker-compose volume sharing syntax
Which docker-compose.yml snippet correctly shares a volume named 'shared_data' between two services 'app1' and 'app2'?
Attempts:
2 left
💡 Hint
Named volumes are declared under 'volumes' and referenced with 'volume_name:container_path'.
✗ Incorrect
Option C correctly declares a named volume 'shared_data' and mounts it at /data in both services. Option C uses a host path which is not a named volume. Option C misses the container path. Option C uses a relative host path, not a named volume.
❓ Troubleshoot
advanced2:00remaining
Why data is missing when sharing host directory volume
You mounted a host directory as a volume in two containers to share data. Container A writes a file, but Container B cannot see it. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check the mount options for the volume in Container B.
✗ Incorrect
If Container B mounts the host directory as read-only, it cannot see new files written by Container A if they are not synced properly or permissions prevent visibility. Network differences do not affect volume sharing. Named volumes and bind mounts behave differently but here a host directory is used. Write permissions on Container A affect writing but not visibility in Container B if files exist.
🔀 Workflow
advanced2:00remaining
Steps to share data between containers using volumes
What is the correct order of steps to share data between two running containers using a named volume?
Attempts:
2 left
💡 Hint
Think about creating the volume before using it in containers.
✗ Incorrect
You must first create the named volume, then start the first container mounting it, write data inside, and finally start the second container mounting the same volume to access the data.
✅ Best Practice
expert3:00remaining
Best practice for sharing sensitive data between containers
Which is the best practice for securely sharing sensitive configuration files between multiple containers?
Attempts:
2 left
💡 Hint
Consider security and access control for sensitive data.
✗ Incorrect
Docker secrets or dedicated secrets management tools provide secure storage and controlled access to sensitive data. Named volumes or bind mounts do not encrypt or restrict access by default. Environment variables can leak sensitive data in logs or process lists.