Windows 10 docker公共IP地址,用于从多个容器访问

时间:2020-02-10 08:09:47

标签: docker

我在后台运行了一些docker-compose。
我需要从一个docker-compose容器连接到另一个。
因此,当我运行curl 10.0.0.3:8080时,可以得到预期的答案。问题是团队中的每个开发人员都有一个不同的IP地址来响应此curl调用。

再次,有2个不同的docker-compose运行,我想从一个连接到另一个。

如何使所有PC泊坞窗回答相同的IP地址? (我想避免环境变量)。 例如,我希望IP:10.0.0.3在每个团队成员的PC中均有效。

有可能吗?
解冻

1 个答案:

答案 0 :(得分:0)

在使用docker时使用IP是一种不好的做法,我强烈建议不要这样做。如果使用docker-compose,则只需使用服务名称来引用服务。这样,即使IP发生了变化,您仍然可以连接到您的服务

每个docker-compose实例都在其自己的网络中运行服务。您还可以定义一个网络(Hi! looks like the front-end bundle hasn't updated; after adding the combobox to the view, did you restart the app? Vaadin needs to run mvn Vaadin:prepare-frontend to include the new component. ),然后配置docker-compose连接到该网络。这样,您的所有服务都可以互相看到。

但是,如果您决定继续使用IP,则可以使用一种方法为您的服务设置固定IP。检查Docker-compose referencedocker network create xxxxx部分。