Containers are not linked with docker-compose version 2

前端 未结 2 1178
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 10:18

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

相关标签:
2条回答
  • 2021-02-04 10:29

    Add an environment variable to your ff section of the Docker Compose file (and you can remove the link):

    ff:
      container_name: ff
      image: selenium/node-firefox
      environment:
        - HUB_PORT_4444_TCP_ADDR=hub
      expose:
        - "5555"
    

    Compose version 2 uses a different style of networking. From the upgrading guide:

    environment variables created by links have been deprecated for some time. In the new Docker network system, they have been removed. You should either connect directly to the appropriate hostname or set the relevant environment variable yourself, using the link hostname.

    From the networking documentation:

    links are not required to enable services to communicate - by default, any service can reach any other service at that service’s name.

    The Selenium dockerfile uses version 1 style networking by ENV variable. Here in the code, if that variable isn't set (which Docker used to do) the entry_point.sh command exits. Providing the variable explicitly solves this.

    0 讨论(0)
  • 2021-02-04 10:37

    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

    0 讨论(0)
提交回复
热议问题