我有一个docker-compose文件,我从版本1升级到版本2.
它设置了一个简单的带有Firefox的节点的Selenium中枢.
当我把它设置为版本1它启动罚款.当我使用版本2进行设置时,ff容器返回“不与正在运行的Hub容器关联”并退出.
当我研究它并理解它,是容器之间的联系以某种方式受到损害.
有解决方案吗?我错过了什么吗?
version: '2'
services:
hub:
container_name: hub
image: selenium/hub
ports:
- "8080:4444" # HOST:CONTAINER
expose:
- "4444"
ff:
container_name: ff
image: selenium/node-firefox
links:
- hub
expose:
- "5555"
最佳答案
将一个环境变量添加到Docker Compose文件的ff部分(您可以删除链接):
ff:
container_name: ff
image: selenium/node-firefox
environment:
- HUB_PORT_4444_TCP_ADDR=hub
expose:
- "5555"
Compose版本2使用不同风格的网络.从upgrading guide:
environment variables created by
links
have been deprecated for some
time. In the new Docker network system,they have been removed. You
should either connect directly to the appropriate hostname or set the
relevant environment variable yourself,using the link hostname.
links
are not required to enable services to communicate – by
default,any service can reach any other service at that service’s
name.
Selenium docker文件使用ENV变量的版本1风格的网络.在code中,如果该变量未设置(Docker曾经做过),则entry_point.sh命令将退出.提供变量明确地解决了这一点.