Bird
0
0

A developer runs:

medium📝 Troubleshoot Q7 of 15
Docker - Security
A developer runs:
docker run --read-only alpine sh -c "echo test > /var/log/app.log"
But the command fails. How can this be fixed without removing --read-only?
AMount a writable volume to <code>/var/log</code>
BRemove the <code>sh -c</code> part
CAdd <code>--network=host</code>
DIncrease container CPU shares
Step-by-Step Solution
Solution:
  1. Step 1: Identify cause of failure

    Writing to /var/log/app.log fails because the root filesystem is read-only.
  2. Step 2: Fix by mounting writable volume

    Mounting a writable volume to /var/log allows writes there while keeping root FS read-only.
  3. Final Answer:

    Mount a writable volume to /var/log -> Option A
  4. Quick Check:

    Writable volume needed for write paths on read-only FS [OK]
Quick Trick: Mount writable volume for paths needing writes [OK]
Common Mistakes:
  • Removing shell command does not fix FS writes
  • Network or CPU options unrelated
  • Trying to write without writable mount

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes