0
0
Dockerdevops~20 mins

Read-only filesystem containers in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Read-Only Container Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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"
Atestfile created successfully
Bsh: can't create /tmp/testfile: Read-only file system
CPermission denied
DNo such file or directory
Attempts:
2 left
💡 Hint
Think about what happens when you try to write to a read-only filesystem.
🧠 Conceptual
intermediate
1:30remaining
Purpose of read-only filesystem in containers
Why would you want to run a container with a read-only filesystem?
ATo allow unlimited writes without disk space limits
BTo increase container startup speed
CTo enable container networking features
DTo improve security by preventing writes inside the container
Attempts:
2 left
💡 Hint
Think about how restricting writes can protect the container.
Configuration
advanced
2: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?
Adocker run --rm --read-only -v /host/data:/data:rw alpine
Bdocker run --rm -v /host/data:/data:ro alpine
Cdocker run --rm --read-only -v /host/data:/data:ro alpine
Ddocker run --rm --read-only alpine
Attempts:
2 left
💡 Hint
Remember that the root filesystem is read-only but volumes can be mounted writable.
Troubleshoot
advanced
2: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?
AThe --read-only flag disables all writes including volumes
BThe container image does not support volumes
CThe volume is mounted with read-only permissions on the host
DDocker daemon is not running
Attempts:
2 left
💡 Hint
Check the host directory permissions for the volume mount.
Best Practice
expert
3: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?
AMount a writable volume or tmpfs at the log directory path
BWrite logs inside the container root filesystem
CDisable logging to avoid write errors
DSend logs only to stdout without any volume mounts
Attempts:
2 left
💡 Hint
Think about how to allow writes for logs without changing the root filesystem.