Docker依赖于订单不起作用

时间:2018-04-16 22:34:51

标签: java selenium docker docker-compose dockerfile

我正在尝试使用selenium hub,chrome节点和firefox节点,以及按此顺序运行测试执行脚本的代码。我有节点取决于集线器和代码取决于两个集线器。但是,运行docker-compose --build会先构建代码并尝试在不启动selenium组件的情况下运行。我不确定我做错了什么。

搬运工-compose.yml

version: '3'
services:
  hub:
    image: selenium/hub
    networks:
      robottestsnw: {}
    ports:
    - 4444:4444

  chrome:
    image: selenium/node-chrome
    networks:
      robottestsnw: {}
    depends_on:
      - hub
    shm_size: '2g'
    environment:
      SCREEN_WIDTH: 1920
      SCREEN_HEIGHT: 1080
      HUB_HOST: hub


  firefox:
    image: selenium/node-firefox
    networks:
      robottestsnw: {}
    depends_on:
      - hub
    shm_size: '2g'
    environment:
      HUB_PORT_4444_TCP_ADDR: hub
      SCREEN_WIDTH: 1920
      SCREEN_HEIGHT: 1080
      HUB_HOST: hub

  robottests:
    build: .
    networks:
      robottestsnw: {}
    depends_on:
      - chrome
      - firefox

networks:
  robottestsnw:
    driver: bridge

Dockerfile

# Dockerfile

# Base image
FROM sgrio/java-oracle

RUN apt-get update
RUN apt-get install -y maven

# Copy test project files to the image folder
COPY . /frontend-integration-tests

# Make the folder as a working directory
WORKDIR /frontend-integration-tests

# Install the test project libraries
RUN mvn package
CMD ["java", "-cp", "target/automated-testing 0.0.1-SNAPSHOT.jar", "automated-testing.service.App"]

1 个答案:

答案 0 :(得分:1)

docker-compose up

它按依赖关系顺序启动服务,不确定 docker-compose --build up 。也许您的端口,网络名称定义错误:

hub:
image: selenium/hub
networks:
 - robottestsnw
ports:
 - 4444:4444