简体   繁体   English

如何杀死Docker容器的网络?

[英]How to kill networking to a docker container?

What approach can I use to kill networking to a docker container (ie: make it unreachable from the host OS)? 我可以使用什么方法来杀死与docker容器的网络连接(即:让它从主机操作系统无法访问)? A typical approach for a non-container would be to alter iptables, but for Docker I'm not sure how to go about this. 非容器的典型方法是改变iptables,但对于Docker,我不知道如何解决这个问题。

It's mostly this way by default. 默认情况下,这种方式大部分都是这样。 If you don't expose any ports and don't run network services in the OS (usually you just run your application), there's nothing to reach in the container. 如果您没有expose任何端口并且不在操作系统中运行网络服务(通常只是运行您的应用程序),则容器中无法访问任何内容。

You might clarify precisely what you mean with "reachable". 您可以准确地澄清“可达”的含义。 Reachable from where for what purpose? 可以从哪里到达目的? If you don't expose any ports, your container is not reachable from any other host. 如果您不公开任何端口,则无法从任何其他主机访问您的容器。 Your container may still be "reachable" from other containers within the docker network on the host, so if your concern is other docker containers within the same docker host, docker provides the --icc=false flag to disable inter-container communication , which by default is enabled. 您的容器仍然可以从主机上的docker网络中的其他容器“到达”,因此如果您关注的是同一个--icc=false主机中的其他--icc=false 容器--icc=false提供--icc=false标志来禁用容器间通信 ,默认情况下已启用。 More info here in the docs . 更多信息,请参阅文档

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

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