简体   繁体   English

Docker无法连接到主机

[英]Docker cannot connect to the host machine

Im trying to set up a connection between my Docker container and my host that it is run on. 我试图在我的Docker容器和运行它的主机之间建立连接。 Ive read Access host database from a docker container , and added the host ip to the hostfile of the Docker container, however it still will not respond to pings. 我已经 Docker容器读取Access主机数据库 ,并将主机ip添加到Docker容器的主机文件中,但是它仍然不会响应ping。

Im hosting my servers on an AWS box, and the ports 80, 8080 are open. 我将服务器托管在AWS盒子上,并且端口80、8080已打开。

How can I get the host sever to respond to pings from the container? 如何让主机服务器响应来自容器的ping?

Thanks. 谢谢。

You can run Docker container using "--net=host" option, then the container will share the same network namespaces with the host node. 您可以使用“ --net = host”选项运行Docker容器,然后该容器将与主机节点共享相同的网络名称空间。

For example: 例如:

sudo docker run -it --net=host ubuntu:14.04 bash

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM