【问题标题】:How to assign public port to port 5900 in docker-compose如何在 docker-compose 中将公共端口分配给端口 5900
【发布时间】:2017-04-01 15:11:09
【问题描述】:

我有以下 YAML 文件:

硒集线器:

image: selenium/hub

ports: 
 - 4444:4444

火狐节点:

image: selenium/node-firefox-debug  

ports:
 - 4577

links: 
 - seleniumhub:hub 

expose: 
 - "5900"

铬节点:

image : selenium/node-chrome-debug

ports:
 - 4578

links:
 - seleniumhub:hub

expose: 
 - "5900"

码头工人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 快速启动终端中运行以下命令时:

docker port 9d2ccb193b54 5900

我在下面:

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

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

【问题讨论】:

    标签: docker selenium-webdriver docker-compose selenium-grid


    【解决方案1】:

    firefoxnode 试试这个配置:

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

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

    【讨论】:

      【解决方案2】:

      公开端口的语法是:

      ports:
        - "host:container"
      

      在你的情况下:

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

      【讨论】:

        猜你喜欢
        • 2019-03-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-12-10
        • 2018-08-10
        相关资源
        最近更新 更多