Docker ignores iptable rules when using “-p :

前端 未结 5 936
广开言路
广开言路 2021-01-31 22:10

Just realized a few days ago that Docker seems to bypass my iptable rules. I am not incredible experienced with Docker nor iptables. Tried a lot of different things the last day

5条回答
  •  长情又很酷
    2021-01-31 22:27

    Ended up doing more or less exactly what larsks said. Just did not add it to the FORWARD chain, I added it to the DOCKER chain instead.

    I've found the same in the docs: https://docs.docker.com/v1.5/articles/networking/#the-world

    Docker will not delete or modify any pre-existing rules from the DOCKER filter chain. This allows the user to create in advance any rules required to further restrict access to the containers.

    Docker's forward rules permit all external source IPs by default. To allow only a specific IP or network to access the containers, insert a negated rule at the top of the DOCKER filter chain. For example, to restrict external access such that only source IP 8.8.8.8 can access the containers, the following rule could be added:

    $ iptables -I DOCKER -i ext_if ! -s 8.8.8.8 -j DROP
    

提交回复
热议问题