Bird
0
0

Consider this command:

medium📝 Command Output Q13 of 15
Docker - Security
Consider this command:
docker run --read-only -v /data alpine sh -c "echo hello > /data/file.txt && cat /data/file.txt"
What will be the output?
Ahello
BPermission denied error
CNo such file or directory error
DEmpty output
Step-by-Step Solution
Solution:
  1. Step 1: Understand --read-only with volume mount

    The container filesystem is read-only, but the /data directory is mounted as a volume, which is writable.
  2. Step 2: Analyze the command behavior

    The command writes "hello" to /data/file.txt and then reads it back. Since /data is writable, this succeeds and outputs "hello".
  3. Final Answer:

    hello -> Option A
  4. Quick Check:

    Writable volume inside read-only container = writable [OK]
Quick Trick: Writable volumes override read-only container filesystem [OK]
Common Mistakes:
  • Assuming entire container is fully read-only including volumes
  • Expecting permission denied on volume writes
  • Confusing volume mount syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes