0
0
Dockerdevops~20 mins

Volumes for persistent data in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Volume Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of the volume listing command?

You ran the command docker volume ls after creating a volume named mydata. What will the output show?

Docker
docker volume ls
A
VOLUME NAME
mydata
B
DRIVER    VOLUME NAME
local     mydata
C
local     mydata
local     otherdata
DError: No volumes found
Attempts:
2 left
💡 Hint

Remember that docker volume ls shows the driver and volume name columns.

🧠 Conceptual
intermediate
1:30remaining
Why use Docker volumes for persistent data?

Which reason best explains why Docker volumes are used for persistent data?

AVolumes allow data to persist even if the container is deleted.
BVolumes make containers run faster by using more CPU.
CVolumes automatically backup data to the cloud.
DVolumes prevent containers from using network resources.
Attempts:
2 left
💡 Hint

Think about what happens to data inside a container when the container is removed.

Configuration
advanced
2:30remaining
Which Docker Compose volume configuration mounts a host directory correctly?

Given this snippet in docker-compose.yml, which option correctly mounts the host directory /home/user/data to the container path /app/data?

Docker
services:
  app:
    image: myapp
    volumes:
A- /app/data:/home/user/data
B- /home/user/data
C- data:/app/data
D- /home/user/data:/app/data
Attempts:
2 left
💡 Hint

Remember the format is host_path:container_path.

Troubleshoot
advanced
2:30remaining
Why does data not persist after container restart?

You created a container with a volume, but after restarting the container, the data inside /data is missing. What is the most likely cause?

AThe volume was not properly mounted to <code>/data</code> in the container.
BThe host disk is full, so data cannot be saved.
CThe container image deletes data on startup automatically.
DDocker volumes do not support data persistence across restarts.
Attempts:
2 left
💡 Hint

Check the volume mount path in the container.

🔀 Workflow
expert
3:00remaining
Order the steps to create and use a Docker volume for persistent data

Put these steps in the correct order to create a Docker volume and use it in a container.

A1,3,2,4
B2,1,3,4
C1,2,3,4
D3,1,2,4
Attempts:
2 left
💡 Hint

Think about creating the volume before using it in a container.