Docker-compose: connect from Docker container to linux host

北慕城南 提交于 2021-01-29 14:58:51

问题


In "naked" Docker, I can use --network=host to make the host reachable from the container through the docker0 interface at 127.0.0.1, or I can reach the host at 172.17.0.1.

Ostensibly docker-compose supports the host networking driver through network_mode: host. Unfortunately, this prevents me from using exposed ports. Containers created using docker-compose don't live on the docker0 interface, and hence can reach the host at some IP address like 172.18.0.1 or 172.19.0.1, decided at startup.

Even once I know that address, it doesn't seem to be reachable from the container.

How can I connect from the container to the host?

来源:https://stackoverflow.com/questions/63999693/docker-compose-connect-from-docker-container-to-linux-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!