查看Container的IP地址
docker inspect <container name or id>| grep IPAddress查看Container的映射的端口
docker port <container name or id>
eg.
docker port d8dac7399647
docker port hfq-jedi-zxf-eden用iptables查看容器映射情况
iptables -t nat -nvL
iptables -t nat -nvL --line-number举例新增端口的映射
##将主机31101 映射到 容器 6379端口
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 31101 -j DNAT --to-destination 192.168.42.2:6379保存iptables规则
iptables-save说明
192.168.42.2 是根据 docker inspect <container name or id>| grep IPAddress 的结果
端口映射完毕后,不能通过docker port d8dac7399647查询到结果
可以通过
iptables -t nat -nvL | grep 192.168.42.2
查询 映射关系版权声明:本文为lsziri原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。