Containers are not linked with docker-compose version 2

Viewed 6546

I have a docker-compose file that I upgraded from version 1 to version 2.

It set ups a simple Selenium hub with a firefox node.

When I set it up as version 1 it launches fine. When I set it up with version 2 the ff container returns "Not linked with a running Hub container" and exits.

As I researched it and understood it , is that the linkage between the containers somehow suffers.

Is there a solution ?? Am I missing something ??

version: '2'
services:
  hub:
    container_name: hub
    image: selenium/hub 
    ports:
      - "8080:4444" # HOST:CONTAINER
    expose:
      - "4444" 

  ff:
    container_name: ff
    image: selenium/node-firefox 
    links:
      - hub
    expose:
      - "5555" 
2 Answers

Below compose file working for me

# To execute this docker-compose yml file use docker-compose -f <file_name> up
# Add the "-d" flag at the end for deattached execution

version: '2'
services:
  firefoxnode:
    image: selenium/node-firefox-debug
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - hub
    environment:
      HUB_HOST: hub
    ports:
      - "32772:5900"

  chromenode:
    image: selenium/node-chrome-debug
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - hub
    environment:
      HUB_HOST: hub
    ports:
      - "32773:5900"

  hub:
    image: selenium/hub
    ports:
      - "4444:4444"

command I use:

 docker-compose -f .\docker-compose.yml up -d

Source :

https://github.com/SeleniumHQ/docker-selenium

Related