How to get the host IP in the docker container
For example, the nginx container may use the host's ruby service
我想大声告诉你2017-05-16 13:19:24
The host uses loopback address aliases to solve this problem.
For example: add the alias IP 10.200.10.1 to the host's loopback address, and then use this IP in the container to connect to the host's service.
Configure local loopback address alias under MAC
我想大声告诉你2017-05-16 13:19:24
1. Pass in docker run --env HOST_IP=192.168.0.160
through the environment variable and obtain
2. Bind the host when running dockerdocker run --network host
,通过ip route
Get