background
- The Docker container running MongoDB in the CentOS of the virtual machine Virtual Box
docker run -p 27017:27017 \ --name mongodbinstance \ --network bridge \ -v $PWD/mongodb-data:/data/db \ -d mongo
- Open CentOS 27017 port
# 放行 27017 TCP 端口 firewall-cmd --add-port 27017/tcp --zone=public --permanent # 重载配置 firewall-cmd --reload
question
- The MongoDB Docker container of the virtual machine cannot be connected with telnet from Windows
# 端口不通 telnet 192.168.56.103 27017
- Can't connect with MongoDB GUI client
(MongoDB GUI client: DMShttps://dms.aliyun.com/static/html/download.htm
)
solve
- Reference https://blog.csdn.net/qq_39354140/article/details/129072064
- Modify ipv4 forwarding status, add
net.ipv4.ip_forward = 1
vi /usr/lib/sysctl.d/00-system.conf
net.ipv4.ip_forward = 1
# 重启网络 systemctl restart network
verify
- Windows successfully connects to 27017 with telnet
- MongoDB GUI client consecutive success