阻止在iptables上运行Docker容器的Postgres端口5432

我正在使用Ubuntu 14.04桌面(准确的说是Xubuntu),并试图用iptables阻止外部对本地运行的Postgres端口5432的访问。 这是我的iptables -S

 -A INPUT -i lo -p tcp -m tcp --dport 5432 -j ACCEPT -A INPUT -p tcp -m tcp --dport 5432 -j DROP 

iptables -L

 Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql DROP tcp -- anywhere anywhere tcp dpt:postgresql 

但不知何故,我的Android上的networking扫描仪应用程序,连接到相同的WiFi,仍然可以看到它。 我可以在Android上通过一个PSQL实用程序对其进行进一步testing,而且我可以看到所有的表格。 我错过了什么?

编辑:可能值得一提的是,这是在Docker容器上运行的Postgres。 这可能与它有关。

挖了更多。 这看起来像修改iptables FORWARD链的Docker行为。

 Chain FORWARD (policy DROP) target prot opt source destination DOCKER-OVERLAY all -- anywhere anywhere DOCKER-ISOLATION all -- anywhere anywhere DOCKER all -- anywhere anywhere Chain DOCKER (2 references) target prot opt source destination ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:postgresql 

这个网站概述了这个问题。

为防止Docker转发对容器的所有访问,在运行容器时指定127.0.0.1

docker run -p 127.0.0.1:5432:5432 postgres