0
0
Dockerdevops~20 mins

Container filesystem is ephemeral in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container Filesystem Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding container filesystem persistence

Which statement best describes why data stored inside a Docker container's filesystem is lost after the container stops?

AThe container filesystem is ephemeral and resets to the original image state on restart.
BDocker automatically backs up container files to the host, so data is never lost.
CContainers use a permanent disk partition on the host that preserves all changes.
DContainer filesystems are shared with the host and changes are instantly saved.
Attempts:
2 left
💡 Hint

Think about what happens when you stop and start a container without volumes.

💻 Command Output
intermediate
2:00remaining
Effect of file creation inside a container

What will be the output of the following commands executed on a Docker container?

docker run --rm ubuntu sh -c "echo hello > /tmp/greeting.txt && cat /tmp/greeting.txt"
docker run --rm ubuntu cat /tmp/greeting.txt

Assuming no volumes are used.

ABoth commands output 'hello'.
BFirst command outputs 'hello', second command outputs nothing and returns an error.
CFirst command outputs nothing, second command outputs 'hello'.
DBoth commands output nothing and return errors.
Attempts:
2 left
💡 Hint

Consider what happens to files created inside a container after it exits.

🔀 Workflow
advanced
2:00remaining
Preserving data across container restarts

You want to keep data created by a container even after it stops. Which Docker command option should you use to achieve this?

AUse <code>docker run --network host</code> to share the host network.
BUse <code>docker run --rm</code> to automatically remove the container after exit.
CUse <code>docker run -v /host/path:/container/path</code> to mount a host directory as a volume.
DUse <code>docker run --memory 512m</code> to limit container memory.
Attempts:
2 left
💡 Hint

Think about how to store data outside the container's ephemeral filesystem.

Troubleshoot
advanced
2:00remaining
Data loss despite using volumes

You mounted a volume to persist data, but after restarting the container, the data is missing. What is the most likely cause?

AThe volume was mounted to the wrong container path, so data was saved elsewhere.
BDocker volumes automatically delete data on container restart.
CThe container image does not support volumes.
DDocker does not allow writing to volumes by default.
Attempts:
2 left
💡 Hint

Check the paths used in the volume mount.

Best Practice
expert
3:00remaining
Ensuring data durability in containerized applications

Which practice best ensures that important application data is not lost when containers are updated or recreated?

AUse ephemeral containers without any data storage to avoid complexity.
BRely on container snapshots to save the container state before updates.
CStore all data inside the container image layers for persistence.
DUse Docker volumes or bind mounts to store data outside the container filesystem.
Attempts:
2 left
💡 Hint

Think about separating data from container lifecycle.