0
0
Dockerdevops~20 mins

Named volumes for data sharing in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Named Volume Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Output of Docker volume creation command
What is the output when you run the command to create a named volume called mydata?
Docker
docker volume create mydata
ACreated volume with ID abc123
BVolume mydata created
CError: volume name required
Dmydata
Attempts:
2 left
💡 Hint
The command returns the volume name if successful.
🧠 Conceptual
intermediate
1:30remaining
Purpose of named volumes in Docker
Which option best describes the main purpose of using named volumes in Docker?
ATo speed up container startup time by caching images
BTo share data between containers and persist data beyond container life
CTo isolate network traffic between containers
DTo limit CPU usage of containers
Attempts:
2 left
💡 Hint
Think about data persistence and sharing.
Configuration
advanced
2:00remaining
Correct Docker Compose volume syntax
Which Docker Compose snippet correctly defines a named volume shared_data and mounts it to /app/data inside the container?
A
volumes:
  shared_data:
services:
  app:
    volumes:
      - /app/data:shared_data
B
volumes:
  - shared_data:/app/data
volumes:
  shared_data:
C
services:
  app:
    volumes:
      - shared_data:/app/data
volumes:
  shared_data:
D
services:
  app:
    volumes:
      - /app/data:shared_data
volumes:
  shared_data:
Attempts:
2 left
💡 Hint
Remember the order is volume_name:container_path and volumes must be declared at root.
Troubleshoot
advanced
2:00remaining
Troubleshooting volume data persistence issue
A developer notices that data written inside a container to a named volume is lost after the container is removed and recreated. What is the most likely cause?
AThe container was started without mounting the named volume
BThe volume was not declared in the Docker Compose file under <code>volumes</code>
CThe volume was mounted as a bind mount to a host directory
DThe container was run with <code>--rm</code> flag
Attempts:
2 left
💡 Hint
Check if the volume is actually connected to the container.
🔀 Workflow
expert
2:30remaining
Order of commands to share data using named volumes
Arrange the steps in the correct order to share data between two containers using a named volume.
A1,2,3,4
B2,1,3,4
C1,3,2,4
D1,2,4,3
Attempts:
2 left
💡 Hint
You must create the volume before using it in containers.