84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
How to get the host IP in the docker container
For example, the nginx container may use the host's ruby service
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
1. Pass in docker run --env HOST_IP=192.168.0.160 through the environment variable and obtain
docker run --env HOST_IP=192.168.0.160
2. Bind the host when running dockerdocker run --network host,通过ip routeGet
docker run --network host
ip route
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
1. Pass in
through the environment variable $HOST_IPdocker run --env HOST_IP=192.168.0.160
through the environment variable and obtain2. Bind the host when running docker
docker run --network host
,通过ip route
Get