Docker compose 网络不绑定 IP 地址

时间:2021-02-16 14:29:52

标签: docker jenkins docker-compose selenium-grid

我正在尝试从 docker compose 文件运行 selenium 网格。在这个 docker compose 中,我设置了一个 Ip 地址,因为我想在另一个 docker 镜像中的 jenkins 上运行测试。只有当我尝试使用设置 ip 地址运行测试时,才会出现以下错误

 org.openqa.selenium.remote.UnreachableBrowserException at RemoteWebDriver.java:573
        Caused by: java.net.UnknownHostException at InetAddress.java:800

这是我的 docker compose 文件

version: "3"
services:
  hub:
    image: selenium/hub
    networks:
      testing_net:
        ipv4_address: 172.28.1.1
    ports:
      - "4444:4444"

    environment:
      GRID_MAX_SESSION: 16
      GRID_BROWSER_TIMEOUT: 3000
      GRID_TIMEOUT: 3000

  chrome:
    image: selenium/node-chrome
    container_name: web-automation_chrome
    depends_on:
      - hub
    environment:
      HUB_PORT_4444_TCP_ADDR: hub
      HUB_PORT_4444_TCP_PORT: 4444
      NODE_MAX_SESSION: 4
      NODE_MAX_INSTANCES: 4
    volumes:
      - /dev/shm:/dev/shm
    ports:
      - "9001:5900"
    links:
      - hub
    networks:
      testing_net:
        ipv4_address: 172.28.1.2  

  firefox:
    image: selenium/node-firefox
    container_name: web-automation_firefox
    depends_on:
      - hub
    environment:
      HUB_PORT_4444_TCP_ADDR: hub
      HUB_PORT_4444_TCP_PORT: 4444
      NODE_MAX_SESSION: 2
      NODE_MAX_INSTANCES: 2
    volumes:
      - /dev/shm:/dev/shm
    ports:
      - "9002:5900"
    links:
      - hub
    networks:
      testing_net:
        ipv4_address: 172.28.1.3  
networks:
  testing_net:
    ipam: 
        driver: default
        config:
            - subnet: 172.28.0.0/16

当我去 172.28.1.1:4444 时,我没有到达 selenium hub

0 个答案:

没有答案