How to Connect mongodb of Host in docker

  docker, question

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 and the internal ip is
(db: mongodb://localhost:27017/wiki)

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 dev eth0 dev eth0 proto kernel scope link src is obtained and the host can be accessed through this address.
Please refer to: …