Bird
0
0

You want to run a container that can modify network settings but nothing else. Which command best limits privileges to only what is needed?

hard📝 Best Practice Q15 of 15
Docker - Security
You want to run a container that can modify network settings but nothing else. Which command best limits privileges to only what is needed?
Adocker run --cap-drop NET_ADMIN myimage
Bdocker run --privileged myimage
Cdocker run --cap-drop ALL --cap-add NET_ADMIN myimage
Ddocker run --cap-add ALL myimage
Step-by-Step Solution
Solution:
  1. Step 1: Understand the goal

    The container should only have network admin rights, no other privileges.
  2. Step 2: Evaluate options

    docker run --cap-drop ALL --cap-add NET_ADMIN myimage drops all capabilities then adds only NET_ADMIN, perfectly limiting privileges.
  3. Step 3: Why others are wrong

    --privileged grants full privileges, --cap-add ALL adds all capabilities (too much), --cap-drop NET_ADMIN removes NET_ADMIN (opposite of goal).
  4. Final Answer:

    docker run --cap-drop ALL --cap-add NET_ADMIN myimage -> Option C
  5. Quick Check:

    Drop all then add needed cap = minimal privileges [OK]
Quick Trick: Drop all caps, then add only needed ones [OK]
Common Mistakes:
  • Using --privileged which grants too many rights
  • Adding all capabilities instead of limiting
  • Dropping the needed capability by mistake

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes