Bird
0
0

You want to run a container with user namespace remapping but need the container's root user to have access to a host directory /data. What is the best way to configure this?

hard📝 Best Practice Q15 of 15
Docker - Security

You want to run a container with user namespace remapping but need the container's root user to have access to a host directory /data. What is the best way to configure this?

AChange ownership of <code>/data</code> on host to the remapped UID range
BDisable user namespace remapping for this container
CRun the container as a non-root user
DMount <code>/data</code> as read-only volume
Step-by-Step Solution
Solution:
  1. Step 1: Understand user namespace remapping effect on file access

    With remapping, container root maps to a high UID on host, so host files must be owned or accessible by that UID.
  2. Step 2: Adjust host directory ownership

    Changing /data ownership to the remapped UID range allows container root to access it safely without disabling remapping.
  3. Final Answer:

    Change ownership of /data on host to the remapped UID range -> Option A
  4. Quick Check:

    Host directory ownership matches remapped UID for access [OK]
Quick Trick: Match host directory ownership to remapped UID [OK]
Common Mistakes:
  • Disabling remapping loses security benefits
  • Running as non-root may not solve access needs
  • Mounting read-only prevents write access

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes