简体   繁体   English

有没有办法允许 Docker 容器连接到主机但不连接到互联网

[英]Is there a way to allow Docker Container to connect to host but not to internet

I want to connect my container to host but not to internet ie It should be a able to connect to a non container process on host eg: localhost:5000我想将我的容器连接到主机而不是互联网,即它应该能够连接到主机上的非容器进程,例如: localhost:5000

but not to internet但不能上网

If you are executing calls from inside a container and you want to address your host , then you cannot use the localhost address (because that would still point to the inside of the container).如果您从容器内部执行调用并且想要寻址您的host ,那么您不能使用localhost地址(因为它仍然指向容器内部)。

So, what you need to do, is use the 0.0.0.0 address ( 0.0.0.0:5000 in your case).因此,您需要做的是使用0.0.0.0地址(在您的情况下为0.0.0.0:5000 )。

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

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