CONTRIBUTING
Contributing Code to Selenium
Much of the magic behind Selenium is the hard work of programmers with backgrounds in Javascript, Java, Ruby, PHP, Python, Perl, C#, HTML and other languages.
We encourage code patches and other contributions - get involved by following the instructions at the main Selenium GitHub. You can also track the activity of the development team by checking out the read-only Selenium Developer Activity Group.
If you do supply a patch we will need you to sign the CLA. We are a part of SFC.
---
README
[](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/build-test.yml)
[](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/deploy.yml)
[](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/helm-chart-release.yml)
[](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/nightly.yml)
[](https://github.com/SeleniumHQ/docker-selenium/actions/workflows/update-dev-beta-browser-images.yml)
[](https://github.com/SeleniumHQ/docker-selenium/releases)
[](https://deepwiki.com/SeleniumHQ/docker-selenium)
[](https://github.com/seleniumhq/docker-selenium/releases/)
Docker images for the Selenium Grid Server
The project is made possible by volunteer contributors who have put in thousands of hours of their own time,
and made the source code freely available under the Apache License 2.0.
These Docker images come with a handful of tags to simplify its usage, have a look at them in one of
our releases.
To get notifications of new releases, add yourself as a "Releases only" watcher.
These images are published to the Docker Hub registry at Selenium Docker Hub.
- Hub: [](https://hub.docker.com/r/selenium/hub/)
- Node-Chrome: [](https://hub.docker.com/r/selenium/node-chrome/)
- Standalone-Chrome: [](https://hub.docker.com/r/selenium/standalone-chrome/)
Helm Chart enables the creation of a Selenium Grid Server in Kubernetes at [](https://artifacthub.io/packages/search?repo=selenium-grid)
Community
Do you need help to use these Docker images?
Talk to us at https://www.selenium.dev/support/
Contents
* Community
* Contents
* System Recommendations
* Quick start
* Try them out in a ready-to-use GitPod environment!
* Experimental Multi-Arch amd64/aarch64/armhf Images
* Nightly Images
* Dev and Beta Channel Browser Images
* Dev and Beta Standalone Mode
* Dev and Beta on the Grid
* Single Node/Standalone Image With All Browsers
* Environment Variables
* Execution modes
* Standalone
* Hub and Nodes
* Fully distributed mode - Router, Queue, Distributor, EventBus, SessionMap and Nodes
* Video recording
* Video recording with dynamic file name based on metadata in tests
* Video recording and uploading
* Retain recordings for failed sessions only
* Dynamic Grid
* Configuration example
* Share volumes config of Dynamic Grid container to node browser containers
* Execution with Hub & Node roles
* Execution with Standalone roles
* Using Dynamic Grid in different machines/VMs
* Execution with Docker Compose
* Configuring the child containers
* Video recording, screen resolution, and time zones in a Dynamic Grid
* Time zone configuration via env variable
* Deploying to Kubernetes
* Configuring the containers
* SE_OPTS Selenium Configuration Options
* SE_JAVA_OPTS Java Environment Options
SE_BROWSER_ARGS_ Add arguments for launching browser
* Node configuration options
* Node configuration relay commands
* Setting Sub Path
* Setting Screen Resolution
* Grid Url and Session Timeout
* Session request timeout
* Increasing session concurrency per container
* Running in Headless mode
* Stopping the Node/Standalone after N sessions have been executed
* Automatic browser leftovers cleanup
* Mask sensitive information in console logs
* Secure Connection
* Browser language and locale
* Managing processes in container
* Building the images
* Build the images with specific versions
* Upgrade browser version in the images
* Upgrade browser and driver versions in the images
* Waiting for the Grid to be ready
* Adding a HEALTHCHECK to the Grid
* Using a bash script to wait for the Grid
* Install certificates for Chromium-based browsers
* Alternative method: Add certificates to existing Selenium based images for browsers
* Debugging
* Using a VNC client
* Using your browser (no VNC client is needed)
* Disabling VNC
* Tracing in Grid
* Troubleshooting
* --shm-size="2g"
* Headless
* Mounting volumes to retrieve downloaded files
* Mounting volumes to retrieve video files
* Stargazers over time
System Recommendations
- Docker Engine 26.1.4 or later
- Docker Compose v2.34.0 or later
- Docker Buildx v0.25.0 or later
- Kubernetes v1.26.15 or later
Quick start
1. Start a Docker container with Firefox
docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-firefox:4.47.0-202608082. Point your WebDriver tests to http://localhost:4444
3. That's it!
4. (Optional) To see what is happening inside the container, head to <http://localhost:7900/?autoconnect=1&resize=scale&password=secret>.
For more details about visualising the container activity, check the Debugging section.
:point_up: When executing docker run for an image that contains a browser please use
the flag --shm-size=2g to use the host's shared memory.
:point_up: Always use a Docker image with a full tag to pin a specific browser and Grid version.
See Tagging Conventions for details.
Try them out in a ready-to-use GitPod environment!
[](https://gitpod.io/#https://github.com/SeleniumHQ/docker-selenium)
___
Experimental Multi-Arch amd64/aarch64/armhf Images
From image tag based 4.21.0 onwards, the architectures supported by this project are as below:
| Architecture | Available |
|:-------------------------:|:---------:|
| x86_64 (aka amd64) | ✅ |
| aarch64 (aka arm64/armv8) | ✅ |
| armhf (aka arm32/armv7l) | ❌ |
Browser images in multi-arch
The following browsers are available in multi-arch images:
| Architecture | Chrome | Chromium | Firefox | Edge | CfT |
|:-------------------------:|:------:|:--------:|:-------:|:----:|-----|
| x86_64 (aka amd64) | ✅ | ✅ | ✅ | ✅ | ✅ |
| aarch64 (aka arm64/armv8) | ✅ | ✅ | ✅ | ❌ | ❌ |
| armhf (aka arm32/armv7l) | ❌ | ❌ | ❌ | ❌ | ❌ |
Note:
- Running an AMD64 image under emulation on an ARM64 platform is not recommended due to performance and stability issues, or browsers could not launch.
- Google Chrome (google-chrome) now is available for Linux/ARM64 via APT stable channel from v150+. The Chrome (node and standalone) images are available in multi-arch. Older Chrome versions remain AMD64 only; the supported platforms per version are tracked in the browser matrix via the CHROME_PLATFORMS key.
Microsoft does not build Edge (microsoft-edge) for Linux/ARM platforms, hence the Edge (node and standalone) images are only available for AMD64.
- Google does not publish a ChromeDriver build for Linux/ARM64 (Chrome for Testing only ships linux64). On ARM64 the Chrome images use the Chromium driver of the same major version instead, taken from the Debian chromium-driver package archived at NDViet/chromium-stable. Those packages follow the stable channel, hence the Chrome dev and beta images are only available for AMD64.
- We also supply Chrome for Testing (CfT), but it is only available for Linux/AMD64.
- For older Linux/ARM setups you can also use the open source Chromium browser. The Chromium (node and standalone) images are available in multi-arch.
$ docker run --rm -it -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 2g selenium/standalone-chromium:latest- Mozilla Firefox now is available for Linux/ARM64 via APT stable channel from v136+. The Firefox (node and standalone) images are available in multi-arch.
~~Multi-arch images are tested on CircleCI with resource class Linux/ARM64. See the status below.~~ (Moved to GitHub Actions)
[](https://dl.circleci.com/status-badge/redirect/gh/SeleniumHQ/docker-selenium/tree/trunk)
History of the multi-arch images
For experimental docker container images, which run on platforms such as the Apple M-series or Raspberry Pi,
the repository at
seleniumhq-community/docker-seleniarm provided images which
are published on the Seleniarm Docker Hub registry.
See issue #1076 for more information on these images.
Now, the fork seleniumhq-community/docker-seleniarm was merged.
Build the multi-arch images locally
We recommend to enable the experimental feature containerd image store in Docker Engine.containerd understands multiplatform images, where a single image tag can refer to different variants covering a range of OS and hardware architectures.
It simplifies the process of building, storing, and distributing images across different platforms.
A single command to enable that feature in Docker Engine:
make set_containerd_image_storeNoted: That command is only compatible with Ubuntu. For users use Docker Desktop on macOS, it can be enabled easily via
Settings > General > Use containerd for pulling and storing imagesTo build all the images for multiplatform at once, run the following command:
PLATFORMS=linux/amd64,linux/arm64 make allTo build the images for a specific platform, run the following command:
PLATFORMS=linux/arm64 make allBy default, without specifying the PLATFORMS variable, the images are built with current host architecture.
Similarly, if you are using host ARM64 architecture, you can build the images for AMD64 architecture by running the following command:
PLATFORMS=linux/amd64 make all___
Nightly Images
Nightly images are built on top of the Nightly build on the upstream project Selenium with the latest changes on main branch in this repository. The image tag is nightly. This is not recommended to use images in production. It is only for testing purpose.
$ docker run -d -p 4442-4444:4442-4444 --name selenium-hub selenium/hub:nightlyCheck out the docker compose to get started with Nightly images docker-compose-v3-full-grid-nightly.yml
Dev and Beta Channel Browser Images
To run tests or otherwise work with pre-release browsers, Google, Mozilla, and Microsoft maintain a Dev and Beta release channel for those who need to see what's soon to be released to the general population.
Dev and Beta Standalone Mode
Here are the instructions to run them in Standalone mode:
Chrome Beta:
$ docker run --platform linux/amd64 --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-chrome:betaChrome Dev:
$ docker run --platform linux/amd64 --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-chrome:devFirefox Beta:
$ docker run --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-firefox:betaFirefox Dev:
$ docker run --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-firefox:devEdge Beta:
$ docker run --platform linux/amd64 --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-edge:betaEdge Dev:
$ docker run --platform linux/amd64 --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-edge:devChrome for Testing Beta:
$ docker run --platform linux/amd64 --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-chrome-for-testing:betaChrome for Testing Dev:
$ docker run --platform linux/amd64 --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-chrome-for-testing:devChrome for Testing Canary:
$ docker run --platform linux/amd64 --rm -it -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-chrome-for-testing:canaryDev and Beta on the Grid
docker-compose-v3-beta-channel.yml:
To execute this docker compose yml file use docker compose -f docker-compose-v3-beta-channel.yml up
Add the -d flag at the end for detached execution
To stop the execution, hit Ctrl+C, and then docker compose -f docker-compose-v3-beta-channel.yml down
services:
chrome:
image: selenium/node-chrome:beta
platform: linux/amd64
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub edge:
image: selenium/node-edge:beta
platform: linux/amd64
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
firefox:
image: selenium/node-firefox:beta
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
chrome-for-testing:
image: selenium/node-chrome-for-testing:beta
platform: linux/amd64
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
selenium-hub:
image: selenium/hub:latest
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
docker-compose-v3-dev-channel.yml:
To execute this docker compose yml file use docker compose -f docker-compose-v3-dev-channel.yml up
Add the -d flag at the end for detached execution
To stop the execution, hit Ctrl+C, and then docker compose -f docker-compose-v3-dev-channel.yml down
services:
chrome:
image: selenium/node-chrome:dev
platform: linux/amd64
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub edge:
image: selenium/node-edge:dev
platform: linux/amd64
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
firefox:
image: selenium/node-firefox:dev
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
chrome-for-testing:
image: selenium/node-chrome-for-testing:dev
platform: linux/amd64
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
selenium-hub:
image: selenium/hub:latest
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
For more information on the Dev and Beta channel container images, see the blog post on Dev and Beta Channel Browsers via Docker Selenium.
Single Node/Standalone Image With All Browsers
From image tag 4.35.0 onwards, a single Node/Standalone image is available with all browsers are pre-installed. Those images are selenium/standalone-all-browsers (standalone all in one), selenium/node-all-browsers (for Hub-Node mode).
These two images are suitable for users:
- Prefer a single container with "all-in-one" includes Selenium Grid and popular browsers.
- Don't care about the image size, prefer the convenience.
- Lightweight workload, able to figure out for yourself the resource consumption.
According to multi-arch support, browsers are available in images selenium/node-all-browsers and selenium/standalone-all-browsers would be different per architecture.
| Browser / Arch | x86_64 (aka amd64) | aarch64 (aka arm64/armv8) |
|----------------|--------------------|---------------------------|
| Chrome | ✅ | ✅ |
| Edge | ✅ | ❌ |
| Firefox | ✅ | ✅ |
| Chromium | ✅ | ✅ |
Both Chrome and Chromium browser binary are available in image arch linux/amd64. However, Chrome browser binary is activated by default. In case you want to switch to Chromium browser binary, you can set environment variable SE_BROWSER_BINARY_LOCATION_CHROME=/usr/bin/chromium.
Via environment variable SE_NODE_ENABLE_BROWSER_<BROWSER>, with <BROWSER> is the name of browser in uppercase (e.g. CHROME, FIREFOX, EDGE). You can disable a browser to be installed in the Node/Standalone image all browsers.
For example with image linux/amd64 and linux/arm64, you can disable Firefox browser by setting environment variable SE_NODE_ENABLE_BROWSER_FIREFOX=false.
For example with image linux/amd64, you can disable Chrome browser by setting environment variable SE_NODE_ENABLE_BROWSER_CHROME=false. Similar for Edge browser, set SE_NODE_ENABLE_BROWSER_EDGE=false.
Here is list of environment variables which support suffix _<BROWSER> in Node/Standalone image all browsers:
SE_NODE_STEREOTYPE
SE_NODE_BROWSER_NAME
SE_NODE_BROWSER_VERSION
SE_NODE_PLATFORM_NAME
SE_BROWSER_BINARY_LOCATION
SE_NODE_STEREOTYPE_EXTRA
SE_NODE_MAX_SESSIONSEnvironment Variables
Checkout full list of environment variables here.
How to update or contribute to list of environment variables? Follow below steps:
1. Refresh the list to pick up new environment variables or default value
make update_list_env_varsThe script can be updated in scripts/generate_list_env_vars/extract_env.py.
2. Update the description for each environment variable in the file scripts/generate_list_env_vars/description.yaml.
3. Run the command in step (1) one more time to update the list of environment variables with new descriptions.
Execution modes
Standalone
#### Firefox
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-firefox:4.47.0-20260808#### Chrome
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:4.47.0-20260808#### Edge
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-edge:4.47.0-20260808#### All browsers in single container
docker run -d -p 4444:4444 --shm-size="3g" selenium/standalone-all-browsers:4.47.0-20260808_Note: Only one Standalone container can run on port_ 4444 _at the same time._
___
Hub and Nodes
There are different ways to run the images and create a Grid with a Hub and Nodes, check the following options.
#### Docker networking
The Hub and Nodes will be created in the same network and they will recognize each other by their container name.
A Docker network needs to be created as a first step.
##### macOS/Linux
Hub and multiple browser Node containers
$ docker network create grid
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
selenium/node-chrome:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
selenium/node-edge:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
selenium/node-firefox:4.47.0-20260808Hub and single Node container with all browsers
$ docker network create grid
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="3g" \
selenium/node-all-browsers:4.47.0-20260808##### Windows PowerShell
Hub and multiple browser Node containers
$ docker network create grid
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub
--shm-size="2g"
selenium/node-chrome:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub
--shm-size="2g"
selenium/node-edge:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub
--shm-size="2g"
selenium/node-firefox:4.47.0-20260808Hub and single Node container with all browsers
$ docker network create grid
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub
--shm-size="3g"
selenium/node-all-browsers:4.47.0-20260808When you are done using the Grid, and the containers have exited, the network can be removed with the following command:
`` ##### Hub - Machine/VM 1 ###### macOS/Linux ###### macOS/Linux ###### macOS/Linux ###### macOS/Linux bashRemoves the grid network
$ docker network rm grid#### Using different machines/VMs
The Hub and Nodes will be created on different machines/VMs, they need to know each other's IPs to
communicate properly. If more than one node will be running on the same Machine/VM, they must be
configured to expose different ports.
$ docker run -d -p 4442-4444:4442-4444 --name selenium-hub selenium/hub:4.47.0-20260808##### Node Chrome - Machine/VM 2
$ docker run -d -p 5555:5555 \
--shm-size="2g" \
-e SE_EVENT_BUS_HOST=<ip-from-machine-1> \
-e SE_NODE_HOST=<ip-from-machine-2> \
selenium/node-chrome:4.47.0-20260808###### Windows PowerShell
$ docker run -d -p 5555:5555
--shm-size="2g"
-e SE_EVENT_BUS_HOST=<ip-from-machine-1>
-e SE_NODE_HOST=<ip-from-machine-2>
selenium/node-chrome:4.47.0-20260808##### Node Edge - Machine/VM 3
$ docker run -d -p 5555:5555 \
--shm-size="2g" \
-e SE_EVENT_BUS_HOST=<ip-from-machine-1> \
-e SE_NODE_HOST=<ip-from-machine-3> \
selenium/node-edge:4.47.0-20260808###### Windows PowerShell
$ docker run -d -p 5555:5555
--shm-size="2g"
-e SE_EVENT_BUS_HOST=<ip-from-machine-1>
-e SE_NODE_HOST=<ip-from-machine-3>
selenium/node-edge:4.47.0-20260808##### Node Firefox - Machine/VM 4
$ docker run -d -p 5555:5555 \
--shm-size="2g" \
-e SE_EVENT_BUS_HOST=<ip-from-machine-1> \
-e SE_NODE_HOST=<ip-from-machine-4> \
selenium/node-firefox:4.47.0-20260808###### Windows PowerShell
$ docker run -d -p 5555:5555
--shm-size="2g"
-e SE_EVENT_BUS_HOST=<ip-from-machine-1>
-e SE_NODE_HOST=<ip-from-machine-4>
selenium/node-firefox:4.47.0-20260808##### Node Chrome - Machine/VM 4
$ docker run -d -p 5556:5556 \
--shm-size="2g" \
-e SE_EVENT_BUS_HOST=<ip-from-machine-1> \
-e SE_NODE_HOST=<ip-from-machine-4> \
-e SE_NODE_PORT=5556 \
selenium/node-chrome:4.47.0-20260808###### Windows PowerShell
$ docker run -d -p 5556:5556
--shm-size="2g"
-e SE_EVENT_BUS_HOST=<ip-from-machine-1>
-e SE_NODE_HOST=<ip-from-machine-4>
-e SE_NODE_PORT=5556
selenium/node-chrome:4.47.0-20260808
#### Docker Composeorg.openqa.selenium.grid.distributor.selector.DefaultSlotSelector
Docker Compose is the simplest way to start a Grid. Use the
linked resources below, save them locally and check the execution instructions on top of each file.##### Version 2
docker-compose-v2.yml##### Version 3
docker-compose-v3.ymlTo stop the Grid and cleanup the created containers, run
docker compose down.##### Version 3 with Swarm support
docker-compose-v3-swarm.yml___
Fully distributed mode - Router, Queue, Distributor, EventBus, SessionMap and Nodes
It is possible to start a Selenium Grid with all its components apart. For simplicity, only an
example with docker compose will be provided. Save the file locally, and check the execution
instructions on top of it.
docker-compose-v3-full-grid.yml#### Distributor configuration
| Environment variable | Option | Type | Default value | Description |
|--------------------------------|-----------------------------|---------|---------------|-----------------------------------------------------------------------------------------------------------------------|
|SE_REJECT_UNSUPPORTED_CAPS|--reject-unsupported-caps| boolean |false| Allow the Distributor to reject a request immediately if the Grid does not support the requested capability. |
|SE_HEALTHCHECK_INTERVAL|--healthcheck-interval| int |120| This ensures the server can ping all the Nodes successfully after an interval. |
|SE_DISTRIBUTOR_SLOT_SELECTOR|--slot-selector| string | `| Full class name of non-default slot selector. This is used to select a slot in a Node once the Node has been matched. |Distributor component comes with two main built-in Slot Selector implementations
*: Grid’s default strategy (used if you don’t configure anything else). It follows the balanced, least-recently-used approach described above. TheDefaultSlotSelectorwill choose the Node that has been free for the longest time, ensuring no single node is overused when others are idle. This simple strategy has minimal overhead and works well for most general testing scenarios where an even distribution of sessions is desired.org.openqa.selenium.grid.distributor.selector.GreedySlotSelector*
: An alternative built-in provided. TheGreedySlotSelectoraims to maximize node utilization by concentrating sessions on one node before using another. As noted, it will tend to fill up a node’s slots one by one, reducing the number of nodes that are partially utilized at any given time. This strategy is beneficial for resource-intensive or high-concurrency scenarios (for example, load testing or running in an environment where you scale nodes on demand). More insight, let's refer to #2990.selenium/video:ffmpeg-8.1-20260808___
Video recording
Tests execution can be recorded by using the
docker compose
Docker image. One container is needed per each container where a browser is running. This means if you are
running 5 Nodes/Standalone containers, you will need 5 video containers, the mapping is 1-1.Currently, the only way to do this mapping is manually (either starting the containers manually or through
). We are iterating on this process and probably this setup will be more simple in the future.4.20.0The video Docker image we provide is based on the ffmpeg Ubuntu image provided by the
jrottenberg/ffmpeg project, thank you for providing this image and
simplifying our work :tada:From image tag based
onwards, the video Docker image is based on the FFmpeg Ubuntu image provided by/videos
linuxserver/docker-ffmpeg project since the image is available for multi-platform.
Thank you for simplifying our project and helping us move forward with multiple architecture support.Notes:
- If you have questions or feedback, please use the community contact points shown here.
- Please report any bugs through GitHub issues, and provide
all the information requested on the template.
- Video recording for headless browsers is not supported.
- Video recording tends to use considerable amounts of CPU. Normally you should estimate 1CPU per video container,
and 1 CPU per browser container.
- Videos are stored in thedirectory inside the video container. Map a local directory to get the videos.FILE_NAME
- If you are running more than one video container, be sure to overwrite the video file name through the
environment variable to avoid unexpected results.This example shows how to start the containers manually:
$ docker network create grid
$ docker run -d -p 4444:4444 -p 6900:5900 --net grid --name selenium --shm-size="2g" selenium/standalone-chrome:4.47.0-20260808
$ docker run -d --net grid --name video -v /tmp/videos:/videos selenium/video:ffmpeg-8.1-20260808
Run your tests
$ docker stop video && docker rm video
$ docker stop selenium && docker rm selenium
After the containers are stopped and removed, you should see a video file on your machine's/tmp/videosdirectory.docker-compose-v3-video.ymlHere is an example using a Hub and a few Nodes:
SE_VIDEO_FILE_NAME=autoVideo recording with dynamic file name based on metadata in tests
Based on the support of Metadata in tests. When the video recorder is sidecar deployed with the browser node with enabling
and adding metadata to your tests, video file name will extract value of capabilityse:nameand use it as the video file name.For example in Python binding:
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium import webdriver
options = ChromeOptions()
options.set_capability('se:name', 'test_visit_basic_auth_secured_page (ChromeTests)')
driver = webdriver.Remote(options=options, command_executor="http://localhost:4444")
driver.get("https://selenium.dev")
driver.quit()
The output video file name will betest_visit_basic_auth_secured_page_ChromeTests_<sessionId>.mp4.SE_VIDEO_FILE_NAME_SUFFIX=falseIf your test name is handled by the test framework, and it is unique for sure, you also can disable the session id appends to the video file name by setting
.spaceFile name will be trimmed to 255 characters to avoid long file names. Moreover,
character will be replaced by_and only characters alphabets, numbers,-(hyphen),_(underscore) are retained in the file name.SE_VIDEO_FILE_NAME_TRIM_REGEXThe trim regex is able to be customized by setting
environment variable. The default value is[^a-zA-Z0-9-_]. The regex should be compatible with Pythonre.compile()function.se:recordVideoAt deployment level, the recorder container is always up and stays in standby, watching for sessions. Whether a given session is recorded is controlled per session by the
capability, which overrides theSE_RECORD_VIDEOenvironment variable used as the default when the capability is not present:se:recordVideo-
capability present on the session: its value wins for that session (truerecords,falseskips), regardless ofSE_RECORD_VIDEO.se:recordVideo
-capability absent: the recorder falls back toSE_RECORD_VIDEO(defaulttruefor the standalone video image,falsefor the Node images).SE_RECORD_VIDEO=falseThis means you can keep recording disabled by default and opt in per test. For example, with
, the recorder stays in standby and only records sessions that explicitly request it:
Recorded only because the session opts in, even when SE_RECORD_VIDEO=false
options.set_capability('se:recordVideo', True)
Conversely, with recording enabled by default (SE_RECORD_VIDEO=true) you can disable it for a specific session:
options.set_capability('se:recordVideo', False)
This per-session control applies to both recording modes:SE_VIDEO_EVENT_DRIVEN=true
- Event-driven mode (, default in the Node images): the recorder subscribes to the Grid event bus and readsse:recordVideofrom each session's capabilities on theSessionCreatedevent.SE_VIDEO_EVENT_DRIVEN=false
- Shell/polling mode (): the recorder queries the Node/statusendpoint (or the Hub GraphQL endpoint) based on the Node SessionId and extractsse:recordVideofrom the capabilities before deciding whether to start recording.SE_NODE_GRID_URLNotes: For the shell/polling mode to reach the GraphQL endpoint, the recorder container needs to know the Hub URL. The Hub URL can be passed via environment variable
. For exampleSE_NODE_GRID_URLishttp://selenium-hub:4444.Video recording and uploading
RCLONE is installed in the video recorder image. You can use it to upload the videos to a cloud storage service.
Besides the video recording mentioned above, you can enable the upload functionality by setting the following environment variables:
services:
chrome_video:
image: selenium/video:ffmpeg-8.1-20260808
depends_on:
- chrome
environment:
- DISPLAY_CONTAINER_NAME=chrome
- SE_VIDEO_FILE_NAME=auto
- SE_VIDEO_UPLOAD_ENABLED=true
- SE_UPLOAD_DESTINATION_PREFIX=s3://mybucket/path
- RCLONE_CONFIG_S3_TYPE=s3
- RCLONE_CONFIG_S3_PROVIDER=GCS
- RCLONE_CONFIG_S3_ENV_AUTH=true
- RCLONE_CONFIG_S3_REGION=asia-southeast1
- RCLONE_CONFIG_S3_LOCATION_CONSTRAINT=asia-southeast1
- RCLONE_CONFIG_S3_ACL=private
- RCLONE_CONFIG_S3_ACCESS_KEY_ID=xxx
- RCLONE_CONFIG_S3_SECRET_ACCESS_KEY=xxx
- RCLONE_CONFIG_S3_ENDPOINT=https://storage.googleapis.com
- RCLONE_CONFIG_S3_NO_CHECK_BUCKET=true
SE_VIDEO_FILE_NAME=autowill use the session id as the video file name. This ensures that the video file name is unique to upload./status
Video file name construction automatically works based on Node endpoint(and optional GraphQL endpoint) to get session ID, capabilities.SE_VIDEO_UPLOAD_ENABLED=trueenables upload in the legacy shell-based mode (SE_VIDEO_EVENT_DRIVEN=false). In event-driven mode (the default), this variable is deprecated — upload is enabled automatically whenSE_UPLOAD_DESTINATION_PREFIXis set to a non-empty value.SE_VIDEO_INTERNAL_UPLOAD=true(by default) will use RCLONE installed in the container for upload. If you want to use another sidecar container for upload, set it tofalse.SE_VIDEO_RECORD_STANDALONE| ENV variables per mode | Hub/Nodes | Standalone roles | Dynamic Grid |
|------------------------------------------|-------------------|------------------|----------------|
|(mandatory) |false(default) |true|true|DISPLAY_CONTAINER_NAME
|(mandatory) | user input | user input | (not required) |SE_NODE_PORT
|(optional) |5555|4444| (not required) |SE_NODE_GRID_URL
|(optional) | user input | (not required) | (not required) |RCLONE_For environment variables with prefix
is used to pass remote configuration to RCLONE. You can find more information about RCLONE configuration here.SE_
When using in Dynamic Grid, those variables should be combined with the prefix, for exampleSE_RCLONE_. See below reference for more details.SE_UPLOAD_RETAIN_LOCAL_FILEReference
- Configure video recording and uploading for Hub and Nodes: docker-compose-v3-video-upload.yml- Configure video recording and uploading for Standalone roles: docker-compose-v3-video-upload-standalone.yml
- Configure video recording and uploading for Dynamic Grid (node-docker): docker-compose-v3-video-upload-dynamic-grid.yml
- Configure video recording and uploading for Dynamic Grid standalone (standalone-docker): tests/docker-compose-v3-test-standalone-docker.yaml
Environment variables and default values for upload feature
| Environment variable | Default value | Description |
|-------------------------------|----------------------------------------------|-------------------------------------------------------------------------------------------|
||false| Keep local file after uploading successfully |SE_UPLOAD_COMMAND
||copy| RCLONE command is used to transfer file. Enforcemovewhen retain local file isfalse|SE_UPLOAD_OPTS
||-P --cutoff-mode SOFT --metadata --inplace| Other options belong to RCLONE command can be set. |SE_UPLOAD_CONFIG_FILE_NAME
||upload.conf| Config file for remote host instead of set via env variable prefix SE_RCLONE_* |SE_UPLOAD_CONFIG_DIRECTORY
||/opt/bin| Directory of config file (change it when conf file in another directory is mounted) |SE_VIDEO_EVENT_DRIVEN=trueRetain recordings for failed sessions only
In event-driven mode (
, the default), the video service subscribes to the Grid's ZeroMQ event bus and reacts to session lifecycle events in real time. This enables a retain-on-failure strategy: record every session, but automatically discard the video when the session passes and only keep (and upload) recordings from sessions that fail.Enable it globally with the environment variable:
SE_RETAIN_ON_FAILURE=true
A session is treated as failed when either of the following is true:eventType1. The test code fires a session event whose
contains a substring fromSE_FAILURE_SESSION_EVENTS(default::failed,:failure,:error,:aborted).TIMEOUT
2. The session closes with an abnormal reason —,NODE_REMOVED, orNODE_RESTARTED— instead of the normalQUIT_COMMAND.SE_RETAIN_ON_FAILURE| Environment variable | Default | Description |
|---------------------------|----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
||false| Discard recordings of sessions that pass. Only recordings from failed sessions are retained on disk and queued for upload. |SE_FAILURE_SESSION_EVENTS
||:failed,:failure,:error,:aborted| Comma-separated substrings. Any session event whoseeventTypecontains one of these (case-insensitive) marks the session as failed. |se:retainOnFailureThe
session capability overrides the global container env var for a specific session. For example, to retain the recording of a single session regardless of the global setting:
options.set_capability('se:retainOnFailure', True)
|se:retainOnFailurecap |SE_RETAIN_ON_FAILUREenv | Effective behaviour |true
|--------------------------|----------------------------|----------------------------------|
||false(default) | Retain on failure for this session |false
||true| Always retain for this session |true
| absent || Retain on failure (global default) |false
| absent |(default) | Always retain (global default) |driver.fire_session_event(eventType, payload)#### Firing session events from test code
The Session Event API lets test code push named events directly to the Grid. The video service listens for these events on the ZeroMQ bus and uses them to determine session failure.
Call
from your test. AnyeventTypethat contains a configured failure substring (e.g."test:failed"contains":failed") marks the session as failed.
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium import webdriver
options = ChromeOptions()
options.set_capability('se:name', 'checkout_flow')
options.set_capability('se:retainOnFailure', True) # discard video if this session passes
driver = webdriver.Remote(options=options, command_executor="http://localhost:4444")
try:
driver.get("https://selenium.dev")
# ... test steps ...
except Exception as exc:
# "test:failed" contains ":failed" — matches the default SE_FAILURE_SESSION_EVENTS
driver.fire_session_event("test:failed", {"error": str(exc)})
raise
finally:
driver.quit()
driver.quit()Note: If the test catches an exception and still callsnormally, the session close reason isQUIT_COMMAND(not abnormal). In that case, firing a failure event beforequit()is the only way to mark the session as failed and prevent the recording from being discarded./srvSo, you can control the retain-on-failure strategy fully from test code via session capabilities and fire session event.
Video recordings manager
We utilize File Browser as a video manager. It is a web-based file manager that allows you to manage files and folders in the storage.
The File Browser container dir
should be mounted to the same storage as video recordings stored. For example a compose file:
services:
chrome:
deploy:
mode: replicated
replicas: 3
image: selenium/node-chrome:4.47.0-20260808
platform: linux/amd64
shm_size: 2gb
depends_on:
- selenium-hub
volumes:
- /tmp/videos:/videos
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_RECORD_VIDEO=true
- SE_VIDEO_FILE_NAME=auto
- SE_NODE_GRID_URL=http://selenium-hub:4444
file_browser:
image: filebrowser/filebrowser:latest
container_name: file_browser
restart: always
ports:
- "8081:80"
volumes:
- /tmp/videos:/srv
environment:
- FB_NOAUTH=true
___tomlDynamic Grid
Grid 4 has the ability to start Docker containers on demand, this means that it starts
a Docker container in the background for each new session request, the test gets executed
there, and when the test completes, the container gets thrown away.This execution mode can be used either in the Standalone or Node roles. The "dynamic"
execution mode needs to be told what Docker images to use when the containers get started.
Additionally, the Grid needs to know the URI of the Docker daemon. This configuration can
be placed in a localfile.config.tomlConfiguration example
You can save this file locally and name it, for example,
.
[docker]
Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
start a container with the given image.
configs = [
"selenium/standalone-firefox:4.47.0-20260808", '{"browserName": "firefox"}',
"selenium/standalone-chrome:4.47.0-20260808", '{"browserName": "chrome"}',
"selenium/standalone-edge:4.47.0-20260808", '{"browserName": "MicrosoftEdge"}'
]
host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts", "Binds"]
URL for connecting to the docker daemon
Most simple approach, leave it as http://127.0.0.1:2375, and mount /var/run/docker.sock.
127.0.0.1 is used because internally the container uses socat when /var/run/docker.sock is mounted
If var/run/docker.sock is not mounted:
Windows: make sure Docker Desktop exposes the daemon via tcp, and use http://host.docker.internal:2375.
macOS: install socat and run the following command, socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock,
then use http://host.docker.internal:2375.
Linux: varies from machine to machine, please mount /var/run/docker.sock. If this does not work, please create an issue.
url = "http://127.0.0.1:2375"
Docker image used for video recording
video-image = "selenium/video:ffmpeg-8.1-20260808"
Uncomment the following section if you are running the node on a separate VM
Fill out the placeholders with appropriate values
#[server]
#host = <ip-from-node-machine>
#port = <port-from-node-machine>
Mount the localconfig.tomlfile to the container path/opt/selenium/docker.toml.host-config-keys
This config file path specific for Dynamic Grid (node/standalone docker) by default to avoid conflict with the config file in node browser containers (since users can share volumes config to node browser containers, see below section for details).With the optional config key
under section [docker] in a config.toml file (or CLI option --docker-host-config-keys). Users can specify a list of docker host configuration keys that should be passed to browser containers.docker inspectValid key names for Docker host config can be found in the Docker API documentation or via the command
the node-docker container./home/seluser/DownloadsShare volumes config of Dynamic Grid container to node browser containers
In case you want to access download directory in node browser containers (e.g
) via volumes config of Dynamic Grid container, you can add the following config to theconfig.tomlfile
[docker]
host-config-keys = ["Binds"]
Volumes config in docker compose fileservices:
node-docker:
image: selenium/node-docker:latest
volumes:
- ./assets:/opt/selenium/assets
- ./config.toml:/opt/selenium/docker.toml
- ./downloads:/home/seluser/Downloads
- /var/run/docker.sock:/var/run/docker.sock
environment:
- SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml
/opt/selenium/config.tomlis the default path for the config file in all images. Once volumes config is shared to node browser containers, itsconfig.tomlcould be overwritten by node-docker container config file.config.tomlIn this case, mount your
file to/opt/selenium/docker.tomlin node-docker container. And set the environment variableSE_NODE_DOCKER_CONFIG_FILENAME=docker.tomlto specify that config file name for the startup script.Refer to example docker-compose-v3-test-node-docker.yaml
Execution with Hub & Node roles
This can be expanded to a full Grid deployment, all components deployed individually. The overall
idea is to have the Hub in one virtual machine, and each of the Nodes in separate and more powerful
virtual machines.#### macOS/Linux
$ docker network create grid
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
-v ${PWD}/config.toml:/opt/selenium/docker.toml \
-v ${PWD}/assets:/opt/selenium/assets \
-v /var/run/docker.sock:/var/run/docker.sock \
selenium/node-docker:4.47.0-20260808
#### Windows PowerShell$ docker network create grid
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub
-v ${PWD}/config.toml:/opt/selenium/docker.toml
-v ${PWD}/assets:/opt/selenium/assets -v /var/run/docker.sock:/var/run/docker.sock
selenium/node-docker:4.47.0-20260808
textTo have the assets saved on your host, please mount your host path to /opt/selenium/assets.When you are done using the Grid, and the containers have exited, the network can be removed with the following command:
bash
Removes the grid network
$ docker network rm grid
textExecution with Standalone roles
#### macOS/Linux
bash
docker run --rm --name selenium-docker -p 4444:4444 \
-v ${PWD}/config.toml:/opt/selenium/docker.toml \
-v ${PWD}/assets:/opt/selenium/assets \
-v /var/run/docker.sock:/var/run/docker.sock \
selenium/standalone-docker:4.47.0-20260808
text#### Windows PowerShell
bash
docker run --rm --name selenium-docker -p 4444:4444 -v ${PWD}/config.toml:/opt/selenium/docker.toml
-v ${PWD}/assets:/opt/selenium/assets -v /var/run/docker.sock:/var/run/docker.sock
selenium/standalone-docker:4.47.0-20260808
textUsing Dynamic Grid in different machines/VMs
#### Hub - Machine/VM 1
bash
$ docker run -d -p 4442-4444:4442-4444 --name selenium-hub selenium/hub:4.47.0-20260808
text#### Node Chrome - Machine/VM 2#### macOS/Linux
bash
$ docker run -d -p 5555:5555 \
-e SE_EVENT_BUS_HOST=<ip-from-machine-1> \
-v ${PWD}/config.toml:/opt/selenium/docker.toml \
-v ${PWD}/assets:/opt/selenium/assets \
-v /var/run/docker.sock:/var/run/docker.sock \
selenium/node-docker:4.47.0-20260808
text#### Windows PowerShell
bash
$ docker run -d -p 5555:5555 -e SE_EVENT_BUS_HOST=<ip-from-machine-1>
-v ${PWD}/config.toml:/opt/selenium/docker.toml -v ${PWD}/assets:/opt/selenium/assets
-v /var/run/docker.sock:/var/run/docker.sock selenium/node-docker:4.47.0-20260808
Complete the [server] section in the config.toml file.[docker]
Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
start a container with the given image.
configs = [
"selenium/standalone-firefox:4.47.0-20260808", "{\"browserName\": \"firefox\"}",
"selenium/standalone-chrome:4.47.0-20260808", "{\"browserName\": \"chrome\"}",
"selenium/standalone-edge:4.47.0-20260808", "{\"browserName\": \"MicrosoftEdge\"}"
]
URL for connecting to the docker daemon
Most simple approach, leave it as http://127.0.0.1:2375, and mount /var/run/docker.sock.
127.0.0.1 is used because interally the container uses socat when /var/run/docker.sock is mounted
If var/run/docker.sock is not mounted:
Windows: make sure Docker Desktop exposes the daemon via tcp, and use http://host.docker.internal:2375.
macOS: install socat and run the following command, socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock,
then use http://host.docker.internal:2375.
Linux: varies from machine to machine, please mount /var/run/docker.sock. If this does not work, please create an issue.
url = "http://127.0.0.1:2375"
Docker image used for video recording
video-image = "selenium/video:ffmpeg-8.1-20260808"
Uncomment the following section if you are running the node on a separate VM
Fill out the placeholders with appropriate values
[server]
host = <ip-from-node-machine>
port = <port-from-node-machine>
To have the assets saved on your host, please mount your host path to /opt/selenium/assets.Execution with Docker Compose
Here is an example using a Hub and a Node:
docker-compose-v3-dynamic-grid.yml
Configuring the child containers
Containers can be further configured through environment variables, such as SE_NODE_SESSION_TIMEOUT
and SE_OPTS. When a child container is created, all environment variables prefixed with SE_ will
be forwared and set in the container. You can set the desired environment variables in the
standalone-docker or node-docker containers. The following example sets the session timeout to
700 seconds for all sessions:
#### macOS/Linux
docker run --rm --name selenium-docker -p 4444:4444 \
-e SE_NODE_SESSION_TIMEOUT=700 \
-v ${PWD}/config.toml:/opt/selenium/docker.toml \
-v ${PWD}/assets:/opt/selenium/assets \
-v /var/run/docker.sock:/var/run/docker.sock \
selenium/standalone-docker:4.47.0-20260808
#### Windows PowerShelldocker run --rm --name selenium-docker -p 4444:4444
-e SE_NODE_SESSION_TIMEOUT=700 -v ${PWD}/config.toml:/opt/selenium/docker.toml
-v ${PWD}/assets:/opt/selenium/assets -v /var/run/docker.sock:/var/run/docker.sock
selenium/standalone-docker:4.47.0-20260808
textVideo recording, screen resolution, and time zones in a Dynamic Grid
To record your WebDriver session, you need to add a se:recordVideo
field set to true. You can also set a time zone and a screen resolution,
for example:
json
{
"browserName": "firefox",
"platformName": "linux",
"se:recordVideo": "true",
"se:timeZone": "US/Pacific",
"se:screenResolution": "1920x1080"
}
textAfter running a test, check the path you mounted to the Docker container,
(${PWD}/assets), and you should see videos and session information. From language bindings, you can set the
se:name capability to change output video file name dynamically. For example, in Python binding:
python
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium import webdriveroptions = ChromeOptions()
options.set_capability('se:recordVideo', True)
options.set_capability('se:screenResolution', '1920x1080')
options.set_capability('se:name', 'test_visit_basic_auth_secured_page (ChromeTests)')
driver = webdriver.Remote(options=options, command_executor="http://localhost:4444")
driver.get("https://selenium.dev")
driver.quit()
textAfter test executed, under (${PWD}/assets) you can see the video file name in path /<sessionId>/test_visit_basic_auth_secured_page_ChromeTests.mp4The file name will be trimmed to 255 characters to avoid long file names. Moreover, the
space character will be replaced by _, and only the characters alphabets, numbers, - (hyphen), and _ (underscore) are retained in the file name. (This feat is available once this PR merged)Time zone configuration via env variable
tzdata is installed in based images, and you can set the time zone in container by using the env variable TZ.
By default, the time zone is set to UTC.
List of supported time zones can be found here. For example:
bash
$ docker run --rm --entrypoint="" -e TZ=Asia/Ho_Chi_Minh selenium/node-chromium:latest date +%FT%T%Z
2024-08-28T18:19:26+07
text___Deploying to Kubernetes
Get started to deploy Selenium Grid on Kubernetes, you can refer to YAML files in the kubernetes directory.
To simplify the deployment process, hide the complexity of Kubernetes objects, and provide a more straightforward way to deploy Selenium Grid on Kubernetes, we offer a Helm chart to deploy Selenium Grid to Kubernetes.
Read more details at the Helm chart README and chart CONFIGURATION.
- Get started to hands-on with Selenium Grid on Kubernetes. See local env setup with Docker Desktop.
___
Configuring the containers
SE_OPTS Selenium Configuration Options
You can pass
SE_OPTS variable with additional command line parameters for starting a hub or a node.
bash
$ docker run -d -p 4444:4444 -e SE_OPTS="--log-level FINE" --name selenium-hub selenium/hub:4.47.0-20260808
textSE_JAVA_OPTS Java Environment Options
You can pass
SE_JAVA_OPTS environment variable to the Java process.
bash
$ docker run -d -p 4444:4444 -e SE_JAVA_OPTS=-Xmx512m --name selenium-hub selenium/hub:4.47.0-20260808
textSE_BROWSER_ARGS_ Add arguments for launching browser
Instead of adding arguments via the browser options from language bindings, for example:
python
options = ChromeOptions()
options.add_argument('--incognito')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Remote(options=options, command_executor="http://localhost:4444/wd/hub")
textYou also can proactive to force applying arguments directly from (node, standalone or node-docker) container environment variables. Define the environment variable with name starts with SE_BROWSER_ARGS_ and following by config key is up to you (ensure those are unique when you define multiple arguments). For example:
bash
docker run -d -p 4444:4444 \
-e SE_BROWSER_ARGS_INCOGNITO=--incognito \
-e SE_BROWSER_ARGS_DISABLE_DSHM=--disable-dev-shm-usage \
selenium/standalone-chrome:latest
textList chromium command-line arguments for your reference.Note: Currently, this is applicable for node browsers Chrome/Chromium, Edge.
Node configuration options
The Nodes register themselves through the Event Bus. When the Grid is started in its typical Hub/Node
setup, the Hub will be the one acting as the Event Bus, and when the Grid is started with all its five
elements apart, the Event Bus will be running on its own.
In both cases, it is necessary to tell the Node where the Event Bus is, so it can register itself. That is
the purpose of the
SE_EVENT_BUS_HOST, SE_EVENT_BUS_PUBLISH_PORT and SE_EVENT_BUS_SUBSCRIBE_PORT environment
variables.In some cases, for example, if you want to tag a node, it might be necessary to supply a custom stereotype to the node config. The environment variable
SE_NODE_STEREOTYPE
sets the stereotype entry in the node's config.toml. An example config.toml file can be found here: Setting custom capabilities for matching specific Nodes.Here is an example with the default values of these environment variables:
bash
$ docker run -d \
-e SE_EVENT_BUS_HOST=<event_bus_ip|event_bus_name> \
-e SE_NODE_STEREOTYPE="{\"browserName\":\"${SE_NODE_BROWSER_NAME}\", \"browserVersion\":\"${SE_NODE_BROWSER_VERSION}\", \"platformName\":\"${SE_NODE_PLATFORM_NAME}\"}" \
--shm-size="2g" selenium/node-chrome:4.47.0-20260808
textIn another case, if you want to retain the default Node stereotype and append additional capabilities, you can use the SE_NODE_STEREOTYPE_EXTRA environment variable to set your capabilities. Those will be merged to the default stereotype. For example:
bash
$ docker run -d \
-e SE_EVENT_BUS_HOST=<event_bus_ip|event_bus_name> \
-e SE_NODE_STEREOTYPE_EXTRA="{\"myApp:version\":\"beta\", \"myApp:publish:\":\"public\"}" \
--shm-size="2g" selenium/node-chrome:4.47.0-20260808
textThis help setting custom capabilities for matching specific Nodes. For example, you added your custom capabilities when starting the Node, and you want assign a test to run on that Node which matches your capabilities. For example in test code:
python
options = ChromeOptions()
options.set_capability('myApp:version', 'beta')
options.set_capability('myApp:publish', 'public')
driver = webdriver.Remote(options=options, command_executor=SELENIUM_GRID_URL)
textNoted: Your custom capabilities with key values should be in W3C capabilities convention, extension capabilities key must contain a ":" (colon) character, denoting an implementation specific namespace.Noted: Ensure that Node config
detect-drivers = false in config.toml (or --detect-drivers false in CLI option) to make feature setting custom capabilities for matching specific Nodes get working.In addition, default Node stereotype includes capability
se:containerName which can visible in node capabilities, or session capabilities to identify the container name where the node/session is running. The prefixed se:containerName is not included in slot matcher. By default, value is getting from hostname command in container, this value is equivalent to the container_id that you saw via docker ps command. If you want to override this value, you can set the environment variable SE_NODE_CONTAINER_NAME to your desired value. For example, when deploy to Kubernetes cluster, you can assign Pod name to env var SE_NODE_CONTAINER_NAME to track a node is running in which Pod.
yaml
env:
- name: SE_NODE_CONTAINER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
textIn an advanced case, where you control to spawn up a Node container, let it register to Hub, and then trigger a test to be assigned exactly to run on that Node. By default, the value of command $(hostname) is added to capability name container:hostname in Node stereotype. Combine with above feature setting custom capabilities for matching specific Nodes. You can use the hostname of the Node container just spawned up and set it as a custom capability. For example, in Python binding:
bash
$ docker run -d --name my-node-1 -e SE_EVENT_BUS_HOST=localhost \
--shm-size="2g" selenium/node-chrome:4.47.0-20260808
$ docker exec -i my-node-1 hostname
a6971f95bbab
text
python
options = ChromeOptions()
options.set_capability('container:hostname', 'a6971f95bbab')
driver = webdriver.Remote(options=options, command_executor=SELENIUM_GRID_URL)
text_Noted: Those above changes require new image tag where the changeset is included & released._Node configuration relay commands
Relaying commands to a service endpoint that supports WebDriver.
It is useful to connect an external service that supports WebDriver to Selenium Grid. An example of such service could be a cloud provider or an Appium server.
In this way, Grid can enable more coverage to platforms and versions not present locally.
The following is an en example of configuration relay commands.
docker-compose-v3-test-node-relay.yml
If you want to relay commands only,
selenium/node-base is suitable and lightweight for this purpose.
In case you want to configure node with both browsers and relay commands, respective node images can be used.To use environment variables for generate relay configs, set
SE_NODE_RELAY_URL and other variables as below. Those will be used to generate the default relay config in TOML format looks like below.
toml
[relay]
url = "${SE_NODE_RELAY_URL}"
status-endpoint = "${SE_NODE_RELAY_STATUS_ENDPOINT}"
protocol-version = "${SE_NODE_RELAY_PROTOCOL_VERSION}"
configs = [ '${SE_NODE_RELAY_MAX_SESSIONS}', '{"browserName": "${SE_NODE_RELAY_BROWSER_NAME}", "platformName": "${SE_NODE_RELAY_PLATFORM_NAME}", "appium:platformVersion": "${SE_NODE_RELAY_PLATFORM_VERSION}"}' ]
textInstead of input value for each environment variable to construct the default relay stereotype, you can use the SE_NODE_RELAY_STEREOTYPE environment variable to overwrite the default relay stereotype with your custom stereotype.In another case, if you want to retain the default relay stereotype and append additional capabilities, you can use the
SE_NODE_RELAY_STEREOTYPE_EXTRA environment variable to set your capabilities. Those will be merged to the default relay stereotype.To run a sample test with the relayed node, you can clone the project and try below command:
bash
make test_node_relay
textSetting Sub Path
By default, Selenium is reachable at
http://127.0.0.1:4444/. Selenium can be configured to use a custom subpath by specifying the SE_SUB_PATH
environmental variable. In the example below Selenium is reachable at http://127.0.0.1:4444/selenium-grid/
bash
$ docker run -d -p 4444:4444 -e SE_SUB_PATH=/selenium-grid/ --name selenium-hub selenium/hub:4.47.0-20260808
textSetting Screen Resolution
By default, nodes start with a screen resolution of 1920 x 1080 with a color depth of 24 bits and a dpi of 96.
These settings can be adjusted by specifying
SE_SCREEN_WIDTH, SE_SCREEN_HEIGHT, SE_SCREEN_DEPTH, and/or SE_SCREEN_DPI
environmental variables when starting the container.
bash
docker run -d -e SE_SCREEN_WIDTH=1366 -e SE_SCREEN_HEIGHT=768 -e SE_SCREEN_DEPTH=24 -e SE_SCREEN_DPI=74 selenium/standalone-firefox:4.47.0-20260808
textGrid Url and Session Timeout
In some use cases, you might need to set the Grid URL to the Node, for example, if you'd like to access the BiDi/CDP endpoint.
This is also needed when you want to use the new
RemoteWebDriver.builder() or Augmenter() present in Selenium 4
(since they setup the BiDi/CDP connection implicitly). You can do that through the SE_NODE_GRID_URL environment
variable, eg -e SE_NODE_GRID_URL=http://<hostMachine>:4444. Setting this env var is needed if you want to see the live view while sessions are executing.Grid has a default session timeout of 300 seconds, where the session can be in a stale state until it is killed. You can use
SE_NODE_SESSION_TIMEOUT to overwrite that value in seconds.
Session request timeout
A new session request is placed in the Session Queue before it is processed, and the request sits in the queue until a matching
slot is found across the registered Nodes. However, the new session request might timeout if no slot was found. By default, a
request will stay in the queue for up to 300 seconds before it a timeout is reached. In addition, an attempt to process the request
is done every 5 seconds (by default).
It is possible to override those values through environment variables in the Hub and the SessionQueue (
SE_SESSION_REQUEST_TIMEOUT
and SE_SESSION_RETRY_INTERVAL). For example, a timeout of 500 seconds would be SE_SESSION_REQUEST_TIMEOUT=500 and a retry
interval of 2 seconds would be SE_SESSION_RETRY_INTERVAL=2.Increasing session concurrency per container
By default, only one session is configured to run per container through the
SE_NODE_MAX_SESSIONS environment variable. It is
possible to increase that number up to the maximum available processors, this is because more stability is achieved when one
container/browser has 1 CPU to run. However, if you have measured performance and based on that, you think more sessions can be executed in each container, you can
override the maximum limit by setting both
SE_NODE_MAX_SESSIONS to a desired number and SE_NODE_OVERRIDE_MAX_SESSIONS to
true. Nevertheless, running more browser sessions than the available processors is not recommended since you will be overloading
the resources.Overriding this setting has an undesired side effect when video recording is enabled since more than one browser session might be
captured in the same video.
Running in Headless mode
Firefox,
Chrome,
When using headless mode, there's no need for the Xvfb server to be started.
To avoid starting the server you can set the
SE_START_XVFB environment variable to false
(or any other value than true), for example:
bash
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
-e SE_START_XVFB=false --shm-size="2g" selenium/node-chrome:4.47.0-20260808
textFor more information, see this GitHub issue.Noted:
- In new Chrome/Chromium versions (v127+),
SE_START_XVFB is required to be set to true to run in --headless=new mode.
- In new Chrome/Chromium versions (v132+), --headless only runs in the new mode, so you need to set SE_START_XVFB to true when using --headless mode.Stopping the Node/Standalone after N sessions have been executed
In some environments, like Docker Swarm or Kubernetes, it is useful to shut down the Node or Standalone
container after N tests have been executed. For example, this can be used in Kubernetes to terminate the
pod and then scale a new one after N sessions. Set the environment variable
SE_DRAIN_AFTER_SESSION_COUNT to
a value higher than zero to enable this behaviour.
bash
$ docker run -e SE_DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.47.0-20260808
textWith the previous command, the Standalone container will shut down after 5 sessions have been executed.Automatic browser leftovers cleanup
In long-running containers, it can happen that browsers leave some leftovers. These can be stuck browser processes
of jobs that have already finished but failed to fully stop the browser, or temporary files written to the
/tmp
file system (notably on Chrome-based browsers). To avoid these filling up resources like process IDs and file system
usage in the container, there is an automatic cleanup script running every hour in the node containers. This will
clean up old processes and old temporary files. By default, this is disabled. When enabled, this will clean up browsers
running for longer than 2 hours, and files older than 1 day. These can be enabled and tweaked with the following
environment variables:*
SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP: default value false, set to true to enable the cleanup.
* SE_BROWSER_LEFTOVERS_INTERVAL_SECS: default value 3600 (1 hour), cleanup interval in seconds.
* SE_BROWSER_LEFTOVERS_PROCESSES_SECS: default value 7200 (2 hours), browsers running for longer than this time will be killed.
* SE_BROWSER_LEFTOVERS_TEMPFILES_DAYS: default value 1 (1 day), files generated by Chrome-based browsers in /tmp will be removed after these number of days (ignored when using Firefox).If you use Selenium for long-running sessions and expect browsers to be running for longer than 2 hours, either do
not set
SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP to true (leave the default value of false), or tweak
SE_BROWSER_LEFTOVERS_PROCESSES_SECS to set a value higher than your expected long-running browser processes.
bash
$ docker run -e SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP=true --shm-size="2g" selenium/node-chrome:4.47.0-20260808
textWith the previous command, the cleanup will be enabled with the default timings.
bash
$ docker run -e SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP=true \
-e SE_BROWSER_LEFTOVERS_INTERVAL_SECS=7200 \
-e SE_BROWSER_LEFTOVERS_PROCESSES_SECS=3600 \
-e SE_BROWSER_LEFTOVERS_TEMPFILES_DAYS=2 \
--shm-size="2g" selenium/node-chrome:4.47.0-20260808
textWith the previous command, the cleanup will be enabled, but will run every 2 hours (instead of 1), will kill browsers
running longer than 1 hour (instead of 2 hours), and will remove temp files older than 2 days (instead of 1).---
Mask sensitive information in console logs
Few variables output like password, secret, etc. are masked in console logs. For debugging purposes, you can disable it by setting
SE_MASK_SECRETS to falseWhile creating bash script, your can mask the output by using syntax
echo "Current value is $(mask ${YOUR_VARIABLE})SE_MASK_SECRETS_MIN_LENGTH default is 3. It means a long string will be masked to * to avoid exposing length for brute force attack.Secure connection
By default, there are default self-signed certificates available in the image in location
/opt/selenium/secrets includes
- server.jks: truststore file to configure for JVM via system property javax.net.ssl.trustStore when start the server.
- server.pass: file contains the truststore password for JVM via system property javax.net.ssl.trustStorePassword.
- tls.crt: Server certificate for https connection is set to Selenium option --https-certificate.
- tls.key: Server private key (in PKCS8 format) for https connection is set to Selenium option --https-private-key.There are environment variables to configure the secure connection:
| Environment variables | Default | Option of | Description |
|---------------------------------------|-------------------------------------|-----------|-----------------------------------------------|
| SE_ENABLE_TLS |
false | | Enable secure connection with default configs |
| SE_JAVA_SSL_TRUST_STORE | /opt/selenium/secrets/server.jks | JVM | |
| SE_JAVA_SSL_TRUST_STORE_PASSWORD | /opt/selenium/secrets/server.pass | JVM | |
| SE_JAVA_DISABLE_HOSTNAME_VERIFICATION | true | JVM | Disable host checks for components internally |
| SE_HTTPS_CERTIFICATE | /opt/selenium/secrets/tls.crt | Selenium | Set to CLI option --https-certificate |
| SE_HTTPS_PRIVATE_KEY | /opt/selenium/secrets/tls.key | Selenium | Set to CLI option --https-private-key |Via volume mount, you can replace the default certificates with your own certificates.
The self-signed certificate also needs to be trusted by the client (add to system widely bundle trusted CA) to avoid error message relates to SSL handshake when creating RemoteWebDriver.
docker-compose-v3-full-grid-secure.ymlBrowser language and locale
Different browsers have different ways to set the language and locale from binding.
Firefox
Firefox can be configured to use a specific language and locale by setting the profile preference when create WebDriver from binding. In addition, language pack need to be installed as add-on for browser UI language to take effect. For example, to set the browser language and locale to
vi-VN, you can use the following steps:Get the latest Firefox language pack for the desired language e.g. https://download.mozilla.org/?product=firefox-langpack-latest-SSL&lang=vi. Then, you can install the language pack as an add-on when creating the RemoteWebDriver instance.
python
profile = webdriver.FirefoxProfile()
profile.set_preference('intl.accept_languages', 'vi-VN,vi')
profile.set_preference('intl.locale.requested', 'vi-VN,vi')
options = FirefoxOptions()
options.profile = profile
driver = webdriver.Remote(options=options, command_executor="http://selenium-hub:4444/wd/hub")
webdriver.Firefox.install_addon(driver, "/local/path/to/vi.xpi")
driver.get('https://google.com')
textThere is a script to get all available language packs for a given Firefox version. You can run the script to get the language packs to your source. For example:
bash
FIREFOX_VERSION=$(docker run --rm --entrypoint="" selenium/node-firefox:latest firefox --version | awk '{print $3}') \
&& ./NodeFirefox/get_lang_package.sh ${FIREFOX_VERSION} /local/path/to/download
textOr, you can mount the container directory $(readlink -f $(which firefox)))/distribution/extensions to host directory to access packs were pre-built in the container for using in your test script.Managing processes in container
Supervisor is used to manage processes and logs in the container. Few configuration for
supervisord can be set via environment variables as below:| Environment variables | Default |
supervisord config |
|------------------------------|------------------------|-------------------------|
| SE_SUPERVISORD_LOG_LEVEL | info | supervisord.loglevel |
| SE_SUPERVISORD_CHILD_LOG_DIR | /tmp | supervisord.childlogdir |
| SE_SUPERVISORD_LOG_FILE | /tmp/supervisord.log | supervisord.logfile |
| SE_SUPERVISORD_PID_FILE | /tmp/supervisord.pid | supervisord.pidfile |___
Building the images
Clone the repo and from the project directory root you can build everything by running:
bash
$ VERSION=local make build
textIf you need to configure environment variables in order to build the image (http proxy for instance),
simply set an environment variable BUILD_ARGS that contains the additional variables to pass to the
docker context (this will only work with docker >= 1.9)
bash
$ BUILD_ARGS="--build-arg http_proxy=http://acme:3128 --build-arg https_proxy=http://acme:3128" make build
text_Note: Omitting_ VERSION=local _will build the images with the released version but replacing the date for the
current one._If you want to build the image with the host UID/GID, simply set an environment variable
BUILD_ARGS
bash
$ BUILD_ARGS="--build-arg UID=$(id -u) --build-arg GID=$(id -g)" make build
textIf you want to build the image with different default user/password, simply set an environment variable BUILD_ARGS
bash
$ BUILD_ARGS="--build-arg SEL_USER=yourseluser --build-arg SEL_PASSWD=welcome" make build
text___Build the images with specific versions
Based on the latest Dockerfile (by cloning the repo and from the project directory root), you can build the images with a specific combination of Selenium Grid, and browser versions.
For example, you would like to build
node-chrome and standalone-chrome images with the Grid based version 4.17.0, Chrome browser versions 119, 120, 123 respectively.
bash
$ ./tests/build-backward-compatible/bootstrap.sh 4.17.0 119,120,123 chrome
textIn generic, the script takes the following arguments:
- $1 (mandatory): Selenium Grid version. Details are fetching from matrix file
- $2 (mandatory): Browser major version, multiple values separated by comma. Details are fetching from matrix file
- $3 (optional): browser name. If not provided, it will iterate over all the browsers (chrome, edge, firefox)
- $4 (optional): Push image to registry. By default, it is false. If you want to push the image to the registry, set it to true (required Docker login to your namespace done before running the script).To update the browser versions matrix, you can run the following command:
bash
make update_browser_versions_matrix
textTo set your namespace for the images, you can set the environment variable NAME before running the script. For example:
bash
$ export NAME=artifactory.yourcompany.com/selenium
$ ./tests/build-backward-compatible/bootstrap.sh 4.17.0 119,120,123 chrome
textAfter running the script, you will see list images with a full tag to pin specific Grid and browser version following Tagging Conventions---
Upgrade browser version in the images
Selenium server, browser and driver are pre-installed in the image. In case you would like to remain on the same Selenium version and just upgrade the browser and its driver to the latest. You can follow below steps
Clone the repo and from the project directory root you can upgrade by running:
bash
$ VERSION=$EXPECTED_SELENIUM_VERSION make chrome_upgrade_version
textFor example: VERSION=4.16.1 make chrome_upgrade_versionThe new image has tag
$VERSION_YYYYMMDD where YYYYMMDD is the current date.
bash
$ VERSION=$SELENIUM_VERSION make firefox_upgrade_version
text
bash
$ VERSION=$SELENIUM_VERSION make edge_upgrade_version
textYou can refer to detail commands in the Makefile file.---
Upgrade browser and driver versions in the images
| Image name | Support |
|--------------------------------|---------|
| node-chrome, standalone-chrome | ✅ |
There are two ways of usage this feature.
1. Upgrade Chrome and ChromeDriver later in runtime (when starting the container). Set the container environment
SE_UPDATE_CHROME_COMPONENTS to true. For example:
bash
docker run -d -p 4444:4444 -p 5900:5900 --shm-size="2g" -e SE_UPDATE_CHROME_COMPONENTS=true selenium/standalone-chrome:latest
textTradeoff:
Note that after the container gets restarted, updated binaries will be lost unless you call the update script within the build container process (the second usage below).2. Build your own image by reusing image layers with upgrading Chrome and ChromeDriver to the latest
Create a simple Dockerfile as below
Dockerfile
FROM --platform=linux/amd64 selenium/standalone-chrome:latest
RUN /opt/bin/update-chrome-components.sh
text- Option 1: Build your own image tag
bash
docker buildx build --platform linux/amd64 -t selenium/standalone-chrome:my-latest .
text- Option 2: Use Dockerfile in docker compose
yml
services:
chrome:
build:
context: .
dockerfile: Dockerfile
image: selenium/standalone-chrome:my-latest
# Add environments, ports, volumes, etc. as needed
text---Waiting for the Grid to be ready
It is a good practice to check first if the Grid is up and ready to receive requests, this can be done by checking the
/wd/hub/status endpoint.A Grid that is ready, composed of a hub and two nodes, could look like this:
json
{
"value": {
"ready": true,
"message": "Selenium Grid ready.",
"nodes": [
{
"id": "6c0a2c59-7e99-469d-bbfc-313dc638797c",
"uri": "http:\u002f\u002f172.20.1.3:5555",
"maxSessions": 4,
"stereotypes": [
{
"capabilities": {
"browserName": "firefox"
},
"count": 4
}
],
"sessions": [
]
},
{
"id": "26af3363-a0d8-4bd6-a854-2c7497ed64a4",
"uri": "http:\u002f\u002f172.20.1.4:5555",
"maxSessions": 4,
"stereotypes": [
{
"capabilities": {
"browserName": "chrome"
},
"count": 4
}
],
"sessions": [
]
}
]
}
}
textThe "ready": true value indicates that the Grid is ready to receive requests. This status can be polled through a
script before running any test, or it can be added as a HEALTHCHECK
when the docker container is started.Adding a HEALTHCHECK to the Grid
The script check-grid.sh, which is included in the images, can be used to poll the Grid status.
This example checks the status of the Grid every 15 seconds, it has a timeout of 30 seconds when the check is done,
and it retries up to 5 times until the container is marked as unhealthy. Please use adjusted values to fit your needs,
(if needed) replace the
--host and --port parameters for the ones used in your environment.
bash
$ docker network create grid
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub \
--health-cmd='/opt/bin/check-grid.sh --host 0.0.0.0 --port 4444' \
--health-interval=15s --health-timeout=30s --health-retries=5 \
selenium/hub:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
selenium/node-chrome:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
selenium/node-edge:4.47.0-20260808
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
selenium/node-firefox:4.47.0-20260808textNote: The \ line delimiter won't work on Windows-based terminals, try either ^ or a backtick.The container health status can be checked by doing
docker ps and verifying the (healthy)|(unhealthy) status or by
inspecting it in the following way:
bash
$ docker inspect --format='{{json .State.Health.Status}}' selenium-hub
"healthy"
textUsing a bash script to wait for the Grid
A common problem known in docker is that a running container does not always mean that the application inside it is ready.
A simple way to tackle this is by using a "wait-for-it" script, more information can be seen here.
The following script is an example of how this can be done using bash, but the same principle applies if you want to do this with the programming language used to write the tests.
In the example below, the script will poll the status endpoint every second. If the grid does not become ready within 30 seconds, the script will exit with an error code.
bash
#!/bin/bash
wait-for-grid.sh
set -e
url="http://localhost:4444/wd/hub/status"
wait_interval_in_seconds=1
max_wait_time_in_seconds=30
end_time=$((SECONDS + max_wait_time_in_seconds))
time_left=$max_wait_time_in_seconds
while [ $SECONDS -lt $end_time ]; do
response=$(curl -sL "$url" | jq -r '.value.ready')
if [ -n "$response" ] && [ "$response" ]; then
echo "Selenium Grid is up - executing tests"
break
else
echo "Waiting for the Grid. Sleeping for $wait_interval_in_seconds second(s). $time_left seconds left until timeout."
sleep $wait_interval_in_seconds
time_left=$((time_left - wait_interval_in_seconds))
fi
done
if [ $SECONDS -ge $end_time ]; then
echo "Timeout: The Grid was not started within $max_wait_time_in_seconds seconds."
exit 1
fi
textWill require
jq installed via apt-get, else the script will keep printing Waiting without completing the execution.Note: If needed, replace
localhost and 4444 for the correct values in your environment. Also, this script is polling indefinitely, you might want
to tweak it and establish a timeout.Let's say that the normal command to execute your tests is
mvn clean test. Here is a way to use the above script and execute your tests:
bash
$ ./wait-for-grid.sh && mvn clean test
textLike this, the script will poll until the Grid is ready, and then your tests will start.___
Install certificates for Chromium-based browsers
By default, the based image is installed
libnss3-tools and initializes /home/seluser/.pki/nssdb,
so you are able to add your certs with rootless.
If you need to install custom certificates, CA, intermediate CA,
or client certificates (for example, enterprise internal CA)
you can create your own docker image from selenium node image.
The Chromium-based browser uses nssdb as a certificate store.
You can then install all required internal certificates in your Dockerfile like this:There is a utility script packaged in the image that can be used to add your certificates to the
nssdb store and the bundle CA.
The script is /opt/bin/add-cert-helper.sh.- Create a Dockerfile that uses the selenium node image as a base and copies the script to the container, and executes it.
For example, Dockerfile
- If you have to create a set of different certificates and node images. You can create a bootstrap script to do that in one-shot.
For example, bootstrap.sh
The above example can be tested with the following command:
bash
make test_custom_ca_cert
./tests/customCACert/bootstrap.sh
textYou can find more information hereThis way the certificates will be installed and the node will start automatically as before.
___
Alternative method: Add certificates to existing Selenium based images for browsers
As an alternative, you can add your certificate files to existing Selenium images. This practical example
assumes you have a known image to use as a build image and have a way to publish new images to your local
docker registry.
This example uses a RedHat-based distro as a build image (Rocky Linux) but it can be any Linux image of your choice.
Please note that build instruction will vary between distributions. You can check the instructions for Ubuntu
in the previous example.
The example also assumes your internal CA is already in /etc/pki/ca-trust/source/anchors/YOUR_CA.pem,
the default location for Rocky Linux. Alternatively, you can also provide these files from your host and
copy them into the build image.
For Chrome and Edge browsers, the recipe is the same, just adapt the image name (node-chrome or node-edge):
Get a standard image for creating nssdb file
FROM rockylinux:8.6 as build
RUN yum install -y nss-tools
RUN mkdir -p -m755 /seluser/.pki/nssdb \
&& certutil -d sql:/seluser/.pki/nssdb -N --empty-password \
&& certutil -d sql:/seluser/.pki/nssdb -A -t "C,," -n YOUR_CA -i /etc/pki/ca-trust/source/anchors/YOUR_CA.pem \
&& chown -R 1200:1201 /seluserStart from Selenium image and add relevant files from build image
FROM selenium/node-chrome:4.47.0-20260808
USER root
COPY --from=build /seluser/ /home/seluser/
USER seluser
textExample for Firefox:
Get a standard image for working on
FROM rockylinux:8.6 as build
RUN mkdir -p "/distribution" "/certs" && \
cp /etc/pki/ca-trust/source/anchors/YOUR_CA*.pem /certs/ && \
echo '{ "policies": { "Certificates": { "Install": ["/opt/firefox-latest/YOUR_CA.pem"] }} }' >"/distribution/policies.json"Start from Selenium image and add relevant files from build image
FROM selenium/node-firefox:4.47.0-20260808
USER root
COPY --from=build /certs /opt/firefox-latest
COPY --from=build /distribution /opt/firefox-latest/distribution
USER seluser
text___Debugging
This project uses x11vnc as a VNC server to allow users to inspect what is happening
inside the container. Users can connect to this server in two ways:
Using a VNC client
The VNC server is listening to port 5900, you can use a VNC client and connect to it. Feel free to map port 5900 to
any free external port that you wish.
The internal 5900 port remains the same because that is the configured port for the VNC server running inside the container.
You can override it with the
SE_VNC_PORT environment variable in case you want to use --net=host.Here is an example with the standalone images, the same concept applies to the node images.
bash
$ docker run -d -p 4444:4444 -p 5900:5900 --shm-size="2g" selenium/standalone-chrome:4.47.0-20260808
$ docker run -d -p 4445:4444 -p 5901:5900 --shm-size="2g" selenium/standalone-edge:4.47.0-20260808
$ docker run -d -p 4446:4444 -p 5902:5900 --shm-size="2g" selenium/standalone-firefox:4.47.0-20260808
textThen, you would use in your VNC client:
- Port 5900 to connect to the Chrome container
- Port 5901 to connect to the Edge container
- Port 5902 to connect to the Firefox containerIf you get a prompt asking for a password, it is:
secret. If you wish to change this,
you can set the environment variable SE_VNC_PASSWORD.If you want to run VNC without password authentication you can set the environment variable
SE_VNC_NO_PASSWORD=true.If you want to run VNC in view-only mode you can set the environment variable
SE_VNC_VIEW_ONLY=true.If you want to modify the open file descriptor limit for the VNC server process you can set the environment variable
SE_VNC_ULIMIT=4096.Using your browser (no VNC client is needed)
This project uses noVNC to allow users to inspect visually container activity with
their browser. This might come in handy if you cannot install a VNC client on your machine. Port 7900 is used to start
noVNC, so you will need to connect to that port with your browser.
Similarly to the previous section, feel free to map port 7900 to any free external port that you wish.
You can also override it with the
SE_NO_VNC_PORT environment variable in case you want to use --net=host.Here is an example with the standalone images, the same concept applies to the node images.
bash
$ docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:4.47.0-20260808
$ docker run -d -p 4445:4444 -p 7901:7900 --shm-size="2g" selenium/standalone-edge:4.47.0-20260808
$ docker run -d -p 4446:4444 -p 7902:7900 --shm-size="2g" selenium/standalone-firefox:4.47.0-20260808
textThen, you would use in your browser:
- http://localhost:7900/ to connect to the Chrome container
- http://localhost:7901/ to connect to the Edge container
- http://localhost:7902/ to connect to the Firefox containerIf you get a prompt asking for a password, it is:
secret.Disabling VNC
If You are running low on resources, or simply don't need to inspect running sessions, it is possible to not run VNC at all.
Just set
SE_START_VNC=falsetextenvironment variable on the grid startup.___
Tracing in Grid
In order to enable tracing in the Selenium Grid container, the following commands can be executed:
bash
docker network create grid
docker run -d -p 16686:16686 -p 4317:4317 --net grid --name jaeger jaegertracing/all-in-one:1.54
docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.47.0-20260808
docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
-e SE_ENABLE_TRACING=true \
-e SE_OTEL_TRACES_EXPORTER=otlp \
-e SE_OTEL_EXPORTER_ENDPOINT=http://jaeger:4317 \
selenium/node-chrome:4.47.0-20260808
docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
-e SE_ENABLE_TRACING=true \
-e SE_OTEL_TRACES_EXPORTER=otlp \
-e SE_OTEL_EXPORTER_ENDPOINT=http://jaeger:4317 \
selenium/node-edge:4.47.0-20260808
docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
-e SE_ENABLE_TRACING=true \
-e SE_OTEL_TRACES_EXPORTER=otlp \
-e SE_OTEL_EXPORTER_ENDPOINT=http://jaeger:4317 \
selenium/node-firefox:4.47.0-20260808
textYou can also refer to the below docker compose yaml files to be able to start a simple grid (or) a dynamic grid.* Simple Grid v3 yaml file
* Simple Grid v2 yaml file
* Dynamic Grid v3 yaml file
You can view the Jaeger UI and trace your request.
By default, the tracing is enabled in Grid components. Without trace exporter endpoint, it will look up a local instance e.g.
localhost/[0:0:0:0:0:0:0:1]:4117.
In container logs you can see few lines like below:
bash
ERROR (ThrottlingLogger.dolog) Failed to export spans.
The request could not be executed. Error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4117
java.net.ConnectException: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4317
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297)
at okhttp3.internal.connection. ExchangeFinder.findConnection (Exchangefinder.kt: 226)
at okhttp3.internal.connection.okhttps.internal.connection.RealConnection.connect(RealConnection.kt:207)
textIn this case, just simply set SE_ENABLE_TRACING=false to all components container to disable tracing (each component exports its own traces).___
Troubleshooting
All output gets sent to stdout, so it can be inspected by running:
bash
$ docker logs -f <container-id|container-name>
textYou can increase the log output by passing environment variable to the containers:
SE_OPTS="--log-level FINE"
text
--shm-size="2g" Why is
--shm-size 2g necessary?
This is a known workaround to avoid the browser crashing inside a docker container, here are the documented issues for
Chrome and Firefox.
The shm size of 2gb is arbitrary but known to work well, your specific use case might need a different value, it is recommended
to tune this value according to your needs.
Headless
If you see the following selenium exceptions:
Message: invalid argument: can't kill an exited processor
Message: unknown error: Chrome failed to start: exited abnormallyor
[DriverServiceSessionFactory.apply] - Error while creating session with the driver service. Stopping driver service: java.util.concurrent.TimeoutExceptionThe reason _might_ be that you've set the
SE_START_XVFB environment variable to false, but forgot to
actually run Firefox, Chrome or Edge in headless mode.Mounting volumes to retrieve downloaded files
A common scenario is mounting a volume to the browser
container in order to retrieve downloaded files. This
works well in Windows and macOS but not without
workarounds in Linux. For more details, check this
well-documented issue.
For example, while using Linux, you might be starting a
container in the following way:
bash
docker run -d -p 4444:4444 --shm-size="2g" \
-v /home/ubuntu/files:/home/seluser/Downloads \
selenium/standalone-chrome:4.47.0-20260808
textThat will mount the host /home/ubuntu/files directory
to the /home/seluser/Downloads inside the container
(default browser's downloads directory). The
problem happens because the volume will be mounted as
root; therefore, the browser cannot write a file to
that directory because it is running under the user
seluser. This happens because that is how Docker mounts
volumes in Linux, more details in this issue.A workaround for this is to create a directory on the
host and change its permissions before mounting the volume.
Depending on your user permissions, you might need to use
sudo for some of these commands:
bash
mkdir /home/ubuntu/files
chown 1200:1201 /home/ubuntu/files
textAfter doing this, you should be able to download files
to the mounted directory. If you have a better workaround,
please send us a pull request!Mounting volumes to retrieve video files
Similar to mount volumes to retrieve downloaded files. For video files, you might need to do the same
bash
mkdir /tmp/videos
chown 1200:1201 /tmp/videos
`Websocket connections per session get exhausted
org.openqa.selenium.remote.http.ConnectionFailedException: JdkWebSocket initial request execution error
This was reported in #2850.
Actually, from Grid version v4.26.0+, in Node CLI option --connection-limit-per-session (SE_NODE_CONNECTION_LIMIT_PER_SESSION environment variable) is set to 10 by default. Let X be the maximum number of websocket connections per session.This will ensure one session is not able to exhaust the connection limit of the host. Websocket connection might come from enable CDP, BiDi.
Your test scenario or test framework implementation might be creating more than X connections per session, which will lead to the error above. You can optimize your implementation to use less connections per session, or you can increase the limit by setting the environment variable SE_NODE_CONNECTION_LIMIT_PER_SESSION to a value higher than 10 to allow more connections per session.
Stargazers over time
[](https://starchart.cc/SeleniumHQ/docker-selenium)
---