Bird
0
0

You wrote this Dockerfile snippet:

medium📝 Troubleshoot Q14 of 15
Docker - Security
You wrote this Dockerfile snippet:
FROM alpine
USER appuser
CMD ["sh"]

But when running the container, you get a permission denied error. What is the likely cause?
AThe CMD syntax is incorrect
BThe user 'appuser' does not exist in the image
CThe base image alpine does not support USER
DThe container needs root to run sh
Step-by-Step Solution
Solution:
  1. Step 1: Check if user exists in image

    The USER appuser requires that 'appuser' is created in the image, otherwise permission errors occur.
  2. Step 2: Verify other options

    CMD syntax is correct, alpine supports USER, and sh can run as non-root if permissions allow.
  3. Final Answer:

    The user 'appuser' does not exist in the image -> Option B
  4. Quick Check:

    User must exist = B [OK]
Quick Trick: Create user before USER instruction to avoid permission errors [OK]
Common Mistakes:
  • Assuming USER works without creating user
  • Blaming CMD syntax for permission issues
  • Thinking alpine disallows USER instruction

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes