如何在docker-compose中将公共端口分配给端口5900

我有下面的YAML文件:

seleniumhub:

image: selenium/hub ports: - 4444:4444 

firefoxnode:

 image: selenium/node-firefox-debug ports: - 4577 links: - seleniumhub:hub expose: - "5900" 

chromenode:

 image : selenium/node-chrome-debug ports: - 4578 links: - seleniumhub:hub expose: - "5900" 

docker工人ps:

 time="2017-04-01T17:57:44+03:00" level=info msg="Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows" CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9d2ccb193b54 selenium/node-firefox-debug "/opt/bin/entry_po..." 6 seconds ago Up 5 seconds 5900/tcp, 0.0.0.0:32785->4577/tcp dockercompose_firefoxnode_1 4be6223fe043 selenium/node-chrome-debug "/opt/bin/entry_po..." 6 seconds ago Up 5 seconds 5900/tcp, 0.0.0.0:32784->4578/tcp dockercompose_chromenode_1 7d95d3e73016 selenium/hub "/opt/bin/entry_po..." 7 seconds ago Up 6 seconds 0.0.0.0:4444->4444/tcp dockercompose_seleniumhub_1 

但是每当我在Docker快速启动terminal中运行下面的命令:

 docker port 9d2ccb193b54 5900 

我得到如下:

错误:没有为9d2ccb193b54发布公共端口“5900 / tcp”

而且我无法通过VNC连接到节点机器

对于firefoxnode试试这个configuration:

 image: selenium/node-firefox-debug ports: - 4577 - 5900 links: - seleniumhub:hub expose: - "5900" 

expose不会将端口发布到主机,并且只能被链接的服务访问。 它适用于集装箱间通信。 ports将把该端口暴露给主机。

为了暴露端口,语法是:

 ports: - "host:container" 

在你的情况下:

 image: selenium/node-firefox-debug ports: - 4577 - "5900:5900" links: - seleniumhub:hub 

问候