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 1.1.1.1 and the internal ip is 2.2.2.2
(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 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:
https://stackoverflow.com/que …