I have to add some rule to iptables, in the build process it give me an error because i need privilege so is there any way to get around it, i know that there no privilege option in build, or can i build and image without run it ?


It's considered better practice from what I understand to use specific kernel capabilities:

docker run --cap-add NET_ADMIN <image> <command>

should get you what you need. You may need to also add SYS_ADMIN as well.

  • 4
    i want it in build time not in run time – Wissam Roujoulah Jan 24 '17 at 12:33
  • Unfortunately you have to add these flags during runtime. – Patrick Jan 24 '17 at 17:13
  • 1
    As a follow-up, see this thread for more information on the status of this feature: github.com/moby/moby/issues/1916 – Patrick Mar 13 '18 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.