How to get the host IP in a docker container and connect to a service on the host
世界只因有你
世界只因有你 2017-05-16 13:17:24
0
2
2668

How to get the host IP in the docker container

For example, the nginx container may use the host's ruby ​​service

世界只因有你
世界只因有你

reply all(2)
我想大声告诉你

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

through the environment variable $HOST_IP

2. Bind the host when running dockerdocker run --network host,通过ip routeGet

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!