For example, how do I write mongo that connects to the host in docker? Do you need to make additional configuration on the host?
For example, the public ip of the host is 220.127.116.11 and the internal ip is 18.104.22.168
1. Execute the following command on the host
iptables -A INPUT -i docker0 -j ACCEPT
2. Enter the container and execute the command.
root@fdbbff27a91c:/# ip route
default via 172.17.0.1 dev eth0
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.2
172.17.0.1 is obtained and the host can be accessed through this address.
Please refer to: