简体   繁体   中英

Docker for AWS and Selenium Grid - Connection refused / No route to host (Host unreachable)

What I am trying to achieve is a scalable and on-demand test infrastructure using Selenium Grid.

I can get everything up and running but what I end up with is this:

在此输入图像描述

Here are all the pieces:

  1. Docker for AWS (CloudFormation Stack)
  2. docker-selenium
  3. Docker compose file (below)

The "implied" software used are:

Docker swarm

Stacks

Here is what I can accomplish:

  1. Create, log into, and ping all hosts & nodes within the stack, following the guidelines here: deploy Docker for AWS

  2. Deploy using the compose the file at the end of this inquiry by running:

     docker stack deploy -c docker-compose.yml grid 
  3. View Selenium Grid console using the public facing DNS name automatically provided by AWS (upon successful creation of the stack). Here is a helpful entry on the subject: Docker Swarm Mode .

Here is are the contents of the compose file I am using:

version: '3'

services:
  hub:
    image: selenium/hub:3.4.0-chromium
    ports:
      - 4444:4444
    networks:
      - selenium
    environment:
      - JAVA_OPTS=-Xmx1024m
    deploy:
      update_config:
        parallelism: 1
        delay: 10s
      placement:
        constraints: [node.role == manager]

  chrome:
    image: selenium/node-chrome:3.4.0-chromium  
    networks:
      - selenium
    depends_on:
      - hub
    environment:
      - HUB_PORT_4444_TCP_ADDR=hub
      - HUB_PORT_4444_TCP_PORT=4444
    deploy:
    placement:
      constraints: [node.role == worker]

  firefox:
    image: selenium/node-firefox:3.4.0-chromium
    networks:
      - selenium
    depends_on:
      - hub
    environment:
      - HUB_PORT_4444_TCP_ADDR=hub
      - HUB_PORT_4444_TCP_PORT=4444
    deploy:
    placement:
      constraints: [node.role == worker]

networks:
  selenium:

Any guidance on this issue will be greatly appreciated. Thank you.

I have also tried opening up ports across the swarm:

swarm-exec docker service update --publish-add 5555:5555 gird

A quick Google brought up https://github.com/SeleniumHQ/docker-selenium/issues/255 . You need to add the following to the Chrome and Firefox nodes:

entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'

This is because the containers have two IP addresses in Swarm Mode and the nodes are picking up the wrong address and advertising that to the hub. This change will have the nodes advertise their hostname so the hub can find the nodes by DNS instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM