Docker Windows Server 2016:如何仅在主机上显示容器

问题描述:

我想要的容器只能用于虚拟网络上的主机。它适用于Windows Server 2016.

I have containers that I want visible only for the host on a virtual network. It's for a Windows Server 2016.



示例:


  • 我有一个暴露端口27017的Mongo容器
  • 容器地址是192.168.0.1
  • 主机地址是XYZA

=>我希望Mongo只能在192.168.0.1:27017上访问。

=> I want to have Mongo reachable only on 192.168.0.1:27017.

如果我为我的容器使用docker NAT网络,可以在所有接口上访问Mongo(即XYZA:27017可见) 。

If I use a docker NAT network for my container, Mongo is reachable on all interfaces (i.e. X.Y.Z.A:27017 is visible).

顺便说一下,这个命令在windows上不起作用:

By the way, this command does not work on windows:

docker run 127.0.0.1:27017:27017 ... 

感谢您的帮助。

问候,

我不能在我身边重现这个问题。你介意运行docker network ls吗?

I cannot reproduce this issue by my side. Would you mind to run docker network ls?