docker shell

 

忘了暴露docker-compose 的mongo-docker的端口映射

mongo --host 127.0.0.1:27017

查看IP地址:
docker inspect 2c11f47c06ef | grep IPAddress

"SecondaryIPAddresses": null,
"IPAddress": "",
"IPAddress": "172.20.0.2",

docker port 2c11f47c06ef

##将mongo-docker的27017 映射到 容器 27017端口
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 27017 -j DNAT --to-destination 172.20.0.2:27017

iptables -t nat -nvL | grep 172.20.0.2

 

posted @ 2019-03-14 10:30  Adamanter  阅读(92)  评论(0编辑  收藏  举报