sodcalculator

10 Tech How-To

Run Chrome Dev & Beta with Docker Selenium

Guide 10-36219 · Updated · Step by step

This guide shows you how to run both Chrome Dev and Chrome Beta channels inside Docker containers alongside the standard Selenium Grid setup. You’ll be able to launch browser sessions against either channel, which is useful for testing against pre-release features or verifying compatibility before stable release. You’ll need Docker installed and basic familiarity with the command line.

What You’ll Need

  • Docker Engine (20.10 or newer) and Docker Compose (v2) installed.
  • Access to pull images from Docker Hub (no special account required).
  • A terminal or command prompt with internet access.
  • Basic knowledge of Selenium WebDriver and how to point tests at a remote grid.

Step-by-Step

  1. Create a working directory for your Selenium grid setup. For example: mkdir selenium-chrome-channels && cd selenium-chrome-channels.
  2. Create a docker-compose.yml file in that directory. This file defines the Selenium Grid hub and the two Chrome nodes.
  3. Define the Selenium Grid Hub service. Use the official selenium/hub:latest image. Map port 4444 to the host so tests can reach the grid. Example snippet:
    services:
      hub:
        image: selenium/hub:latest
        ports:
          - "4444:4444"
        environment:
          - SE_GRID_MAX_SESSION=4
  4. Add the Chrome Dev node service. Use the image selenium/node-chrome-dev:latest. This image contains the Dev channel of Chrome. Connect it to the hub using the SE_EVENT_BUS_HOST and SE_EVENT_BUS_PUBLISH_PORT environment variables. Example:
      chrome-dev:
        image: selenium/node-chrome-dev:latest
        shm_size: 2gb
        depends_on:
          - hub
        environment:
          - SE_EVENT_BUS_HOST=hub
          - SE_EVENT_BUS_PUBLISH_PORT=4442
          - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
  5. Add the Chrome Beta node service. Use the image selenium/node-chrome-beta:latest. This image contains the Beta channel. Use the same environment variables as the Dev node. Example:
      chrome-beta:
        image: selenium/node-chrome-beta:latest
        shm_size: 2gb
        depends_on:
          - hub
        environment:
          - SE_EVENT_BUS_HOST=hub
          - SE_EVENT_BUS_PUBLISH_PORT=4442
          - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
  6. Start the grid by running docker compose up -d. This pulls the images and starts the hub and both nodes in detached mode.
  7. Verify the nodes register with the hub. Open http://localhost:4444/ui in your browser. You should see two nodes listed, each with a browser name of chrome and a version that corresponds to the Dev or Beta channel (e.g., 120.0.6099.x for Dev, 119.0.6045.x for Beta).
  8. Run a test against the Dev channel. In your test code, set the browser version to the Dev channel version. For example, in Selenium WebDriver (Python):
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    options.browser_version = '120.0.6099.109'  # Replace with your Dev version
    options.platform_name = 'Linux'
    driver = webdriver.Remote(
        command_executor='http://localhost:4444/wd/hub',
        options=options
    )
  9. Run a test against the Beta channel similarly, but set the browser version to the Beta version (e.g., ‘119.0.6045.105’). The hub will route the request to the correct node based on version matching.
  10. Stop the grid when done with docker compose down. This removes the containers but keeps your compose file for future runs.

Common Mistakes

  • Forgetting to set shm_size: Chrome in Docker can crash if the shared memory is too small. Always set shm_size: 2gb for each Chrome node.
  • Using the wrong image tag: The images are named selenium/node-chrome-dev and selenium/node-chrome-beta. Do not confuse them with selenium/node-chrome (stable) or selenium/node-chrome-debug (old name).
  • Not specifying browser version in tests: If your test does not set browser_version, the hub will pick any available Chrome node, which may be stable, Dev, or Beta. Always set the version to target the channel you want.
  • Port conflicts: If port 4444 is already in use, change the host port mapping (e.g., "4445:4444") and update your test’s command executor URL accordingly.
  • Forgetting to update the hub URL: In tests, use http://localhost:4444/wd/hub (or the correct host/port). Some examples use /wd/hub path; it is required for Selenium 3, but in Selenium 4 the path is optional. Including it works for both.

Tips

  • Use a fixed version tag: Instead of :latest, pin the image version (e.g., selenium/node-chrome-dev:4.16.1-20231205) to ensure reproducibility. Check the Selenium Docker Hub page for available tags.
  • Check the browser version dynamically: If you don’t want to hardcode versions, you can query the node’s status via the Grid UI or use the Selenium Grid API to retrieve the exact version, then pass it to your test.
  • Run both channels simultaneously: The grid can handle multiple sessions; you can run tests against Dev and Beta in parallel by using separate test threads or CI jobs.
  • Keep your images updated: Dev and Beta channels update frequently. Run docker compose pull regularly to get the latest images with the newest browser versions.
  • Use a dedicated network: If you have other containers, define a custom network in the compose file to avoid DNS issues.

Troubleshooting

  • Nodes not registering with the hub: Check the logs of the node containers: docker compose logs chrome-dev. Look for error messages about connecting to the event bus. Ensure the SE_EVENT_BUS_HOST is set to the hub service name and the publish/subscribe ports are correct (4442 and 4443).
  • Browser crashes on startup: This is usually due to insufficient shared memory. Confirm shm_size: 2gb is set in the compose file. If it still crashes, try increasing to 4gb.
  • Tests fail with “Session not created” error: The version you specified may not match any node. Check the Grid UI for the exact versions available and update your test accordingly. Also ensure the platform name matches (Linux).
  • Docker Compose command not found: Use docker-compose (with a hyphen) for older versions. Or install the Compose plugin for Docker.
  • Port 4444 already in use: Stop any other Selenium Grid or change the host port mapping in the compose file. Remember to update the URL in your tests.
  • Images fail to pull: Check internet connectivity and Docker Hub access. If you are behind a proxy, configure Docker’s proxy settings.

Frequently Asked Questions

Can I use these images for Chrome stable as well?

Yes, but you should use the selenium/node-chrome image for stable. The Dev and Beta images are specifically for those channels.

How do I know which browser version is in the image?

Check the Grid UI after starting the nodes. It lists the browser version for each node. Alternatively, inspect the image with docker run --rm selenium/node-chrome-dev:latest google-chrome --version (if the binary is named that).

Can I run these nodes on different machines?

Yes, you can run the hub on one machine and the nodes on others. You need to set the SE_EVENT_BUS_HOST to the hub’s IP address and ensure the ports are reachable.

Do I need a Selenium license to use these images?

No, Selenium is open source and the images are freely available on Docker Hub.

Can I use these images with Selenium 3?

The images are designed for Selenium 4, but they may work with Selenium 3 if you use the correct WebDriver protocol. It’s recommended to use Selenium 4 for full compatibility.

How do I update to the latest Dev or Beta version?

Run docker compose pull to fetch the latest images, then docker compose up -d to recreate the containers with the new versions.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →