我想创建一个只接受从某些 IP 到 5432 的连接的数据库机器。我想允许连接到这个数据库机器的其他机器没有运行 docker。我已经docker-machine
使用这个 docker-compose 文件在数字海洋上部署了一个主机:
postgres:
restart: always
image: postgres:latest
volumes:
- /tmp/postgrescont:/tmp
volumes_from:
- data
env_file: .dbenv
ports:
- "5432:5432"
data:
restart: always
image: postgres:latest
volumes:
- /var/lib/postgresql
command: "true"
并试图只允许来自另一个特定主机的流量,如下所示:
$ iptables -A INPUT -p tcp --dport 5432 -s <ip address of certain other host> -j ACCEPT
$ iptables -A INPUT -p tcp --dport 5432 -j DROP # deny other traffic
但是,出于某种原因,我仍然可以从不需要的主机连接。知道为什么它不起作用吗?