October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Run Selenium Tests in Docker

Run Selenium tests in Docker with a Standalone browser container, RemoteWebDriver, reproducible image tags, and private Grid networking.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run Selenium in Docker by starting an official Selenium Standalone browser container, publishing Grid’s port, and pointing your test client’s RemoteWebDriver at http://localhost:4444. For repeatable runs, pin an available image tag; if tests run in another container, connect both containers to the same Docker network and use the Grid container’s name instead of localhost.

What Docker changes about Selenium tests

Selenium Grid accepts WebDriver commands and routes them to browser instances. A test using remote WebDriver sends commands to Grid rather than launching a browser inside the test process. Grid is useful when you need remote execution, multiple browser types or versions, or parallel sessions. Selenium describes Grid’s role and use cases.

For a local run or a straightforward CI job, Standalone is the simplest topology: Grid components and a browser run together in one process. Its default WebDriver endpoint is http://localhost:4444. Selenium’s Grid getting-started guide uses this endpoint.

Start a standalone browser container

Choose the official image for the browser you want to test, and replace <pinned-tag> with an actual tag listed by the project. The example publishes Grid’s port to the host and runs the container in the background:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker run -d --name selenium -p 4444:4444 selenium/standalone-chrome:<pinned-tag>

For Firefox, use the corresponding official Firefox Standalone image and an available tag. Selenium documents its Docker Selenium images and naming on the Docker Selenium project page. Docker Hub is one registry; Selenium announced an official GHCR mirror in April 2026, under the ghcr.io/seleniumhq namespace. See the GHCR announcement for image naming information.

Confirm that the container is running before launching tests:

docker ps --filter name=selenium

Then configure the test framework’s remote WebDriver URL as http://localhost:4444 when the test process runs on the Docker host. Use the remote WebDriver interface supplied by your language binding; the exact constructor and capabilities depend on that binding and the browser you selected.

Connect RemoteWebDriver from another container

Inside a container, localhost means that container itself. If your test runner is containerized, it will not reach the Selenium container at localhost:4444 unless the Grid is in the same network namespace. Put both services on a Docker network and connect to the Grid service or container name, using port 4444.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, create a network and attach the Grid container to it:

docker network create selenium-tests
docker run -d --name selenium --network selenium-tests selenium/standalone-chrome:<pinned-tag>

Attach the test-runner container to selenium-tests as well, then set its RemoteWebDriver URL to http://selenium:4444. The hostname works because it is the Grid container’s name on that shared network. Adapt the service name and network configuration to your actual Compose or CI setup; there is no single hostname that applies to every topology.

Pin versions for reproducible browser runs

A moving tag such as latest can change the browser, driver, or Selenium server between runs. Use an explicit available image tag when browser-version consistency matters or when investigating a browser-specific failure. Check Selenium’s image information and release pages before upgrading, and confirm compatibility among the server image, browser, driver, and client binding. Selenium’s downloads page listed 4.49.0 as stable, released September 9, 2026, when checked on October 3, 2026; release and image tags change, so verify the current values before using them.

Choose between Standalone and a multi-node Grid

Consideration Standalone Multi-node Grid
Setup and operations One container and a simple starting point. Multiple nodes and additional configuration.
Browser coverage Best suited to the browser image you start. Can route sessions across configured browser types and versions.
Concurrency Limited by the capacity of the one container and host. Can support more concurrent sessions if the nodes and host have capacity.

Start with Standalone for one browser and modest demand. Add nodes when you need browser diversity or parallel sessions. Grid can route sessions, but parallel execution is only safe when tests do not collide through shared application state, accounts, data, or other resources. Selenium’s Grid applicability guidance includes illustrative arithmetic about potential time savings; those examples are calculations, not measured benchmark results.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Docker Container Linux Devops Programming Coding T-Shirt
  • Docker, Docker Swarm, Docker Compose, Programmer, Developer, Coding, Programming, Software Engineer, Code, DevOps, Deploy, Deployment, Kubernetes, Salt, Puppet, Chef, Terraform, Container, AWS, Azure, Cloud, Geek, Funny, Computer, Software, Tech, IT
  • Integration, Scrum, Compile, Compilation, Science, Bug, Debug, Python, Linux, Java, Javascript, Scala, Dotnet, Kotlin
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem

Selenium’s current getting-started guidance recommends 1 CPU and 1 GB RAM per browser as a sizing reference, not a guarantee for every workload. Measure resource use in your environment and adjust for the browser, page weight, test behavior, and desired concurrency.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep the Grid endpoint private

A reachable Grid is not just a test endpoint: Selenium warns that an inadequately protected Grid can expose infrastructure and internal web applications or files, and may let third parties run custom binaries. Keep the published port available only to intended test clients. Prefer a private Docker network for container-to-container access, and apply host firewall or network rules so untrusted clients cannot reach it. See Selenium’s Grid security guidance.

Troubleshoot common connection and startup failures

  • Connection refused at localhost:4444: Check that the container is running and that -p 4444:4444 was included. From another container, use the Grid container or service name on a shared network, not localhost.
  • Port 4444 is already in use: Another process may own the host port. Stop that process or publish a different host port, for example -p 4445:4444, and use http://localhost:4445 from the host. Container-to-container clients still use the Grid’s internal port 4444.
  • Image pull fails: Confirm that the image name and version tag exist in the selected registry. Consult the official image project page and, if using GHCR, the mirror announcement.
  • Session creation fails after an upgrade: Check the image tag and browser/driver compatibility, then compare with Selenium’s current release information. Pinning a known-good image tag can make the failure easier to reproduce.
  • Tests pass alone but fail in parallel: Investigate shared test data, accounts, or application state before increasing Grid capacity. More nodes do not isolate resources managed by the application.
  • Slow or unstable browser sessions: Observe CPU and memory while sessions run. Reduce concurrency or increase available resources if the host is saturated; Selenium’s per-browser sizing recommendation is only a starting point.

Or skip the browser setup

If the task is to capture a website rather than run browser assertions, ScreenshotNeo offers a one-request screenshot API and an MCP server for AI agents. It is not a Selenium test runner, but it can avoid configuring a browser container for screenshot capture. A cURL example and the other request options are in the ScreenshotNeo documentation:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with the page verdict and billing status shown in response headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.