Challenge - 5 Problems
Read-Only Container Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of running a read-only container with write attempt
What is the output when you run this Docker command that tries to write a file inside a read-only container?
Docker
docker run --rm --read-only alpine sh -c "echo 'test' > /tmp/testfile"
Attempts:
2 left
💡 Hint
Think about what happens when you try to write to a read-only filesystem.
✗ Incorrect
The container's filesystem is mounted as read-only, so any write operation fails with a 'Read-only file system' error.
🧠 Conceptual
intermediate1:30remaining
Purpose of read-only filesystem in containers
Why would you want to run a container with a read-only filesystem?
Attempts:
2 left
💡 Hint
Think about how restricting writes can protect the container.
✗ Incorrect
Running a container with a read-only filesystem helps improve security by preventing any changes or writes inside the container, reducing attack surface.
❓ Configuration
advanced2:30remaining
Correct Docker run command for read-only container with writable volume
Which Docker command correctly runs a container with a read-only root filesystem but allows writing to /data directory?
Attempts:
2 left
💡 Hint
Remember that the root filesystem is read-only but volumes can be mounted writable.
✗ Incorrect
The --read-only flag makes the root filesystem read-only, but mounting a volume with :rw allows writing to that specific directory.
❓ Troubleshoot
advanced2:00remaining
Troubleshooting write failure in read-only container with volume
You run a container with --read-only and a volume mounted as writable, but writing to the volume still fails. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check the host directory permissions for the volume mount.
✗ Incorrect
If the host directory is read-only or lacks write permissions, the container cannot write to the mounted volume even if it is mounted as writable.
✅ Best Practice
expert3:00remaining
Best practice for logging in read-only containers
What is the best practice to handle application logs when running a container with a read-only filesystem?
Attempts:
2 left
💡 Hint
Think about how to allow writes for logs without changing the root filesystem.
✗ Incorrect
Since the root filesystem is read-only, logs should be written to a mounted writable volume or tmpfs to avoid write errors and preserve logs.