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"
The New “docker compose” Command Docker Compose v2 brings Compose functionality into Docker itself. You'll be able to use Compose wherever the latest Docker CLI is installed, no extra steps required. Underneath, Docker continues to use the features provided by the Compose project.
The Compose file is a YAML file defining services, networks, and volumes for a Docker application. The latest and recommended version of the Compose file format is defined by the Compose Specification. The Compose spec merges the legacy 2.
docker-compose 1.20.
We launched the first version of Compose V2 in June of 2021. Thanks to your feedback, we've made numerous improvements since our initial rollout — and have seen a steady increase in adoption over the last 10 months.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With