Flag
--privileged no longer required. Starting with Docker 1.2, you can run your image with the options --cap-add=NET_ADMIN and --cap-add=NET_RAW , which will allow you to use internal iptables.
It can also be noted that in official Ubuntu images from the Docker Hub package iptables not installed. Therefore, the general instruction should be
apt-get install iptables- start the
--net=host container with the parameters --net=host and --cap-add=NET_ADMIN --cap-add=NET_RAW .
In addition, if you have a docker image in which the iptables package is missing, and you do not want to create a custom image from it, you can start the container with iptables in the same network space. For instance. if you have a container container-without-iptables , and you want to run several container-with-iptables in the same namespace on the network, you can do:
docker run -it --pid=container:container-without-iptables --net=container:container-without-iptables --cap-add sys_admin container-with-iptables
source share