Selenium Grid 4 Setup with Docker — Complete Guide (2026)
Stand up a scalable Selenium Grid 4 in under 10 minutes using Docker Compose. Includes hub-node topology, autoscaling via Kubernetes, session queue tuning, and a full CI recipe.

Last updated 2026-07-20 · 11 min read · By Avinash K
Selenium Grid 4 is a full rewrite — new event bus, session queue, and Kubernetes-native scaling. If you last set up a grid on 3.x, everything you know about JSON wire protocol and static node registration is gone. This guide gets you to a green Chrome + Firefox grid in 10 minutes and shows the autoscale pattern we use in production.
Key takeaways
- The 3 grid topologies (Standalone, Hub-Node, Fully Distributed).
- A copy-paste
docker-compose.ymlfor hub + Chrome + Firefox.- Session queue tuning that eliminates the "no free slots" flakes.
- Kubernetes autoscaling via KEDA + the Selenium chart.
1. Pick a topology
| Topology | When to use |
|---|---|
| Standalone | Local dev, 1 machine, no scale. |
| Hub & Node | Small teams, <100 parallel sessions. |
| Fully Distributed | Enterprise, split router / distributor / queue / event-bus / session-map. |
2. Docker Compose for hub + 2 browser nodes
services:
selenium-hub:
image: selenium/hub:4.24
ports: ["4442:4442", "4443:4443", "4444:4444"]
chrome:
image: selenium/node-chrome:4.24
shm_size: 2gb
depends_on: [selenium-hub]
environment:
SE_EVENT_BUS_HOST: selenium-hub
SE_EVENT_BUS_PUBLISH_PORT: 4442
SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
SE_NODE_MAX_SESSIONS: 4
firefox:
image: selenium/node-firefox:4.24
shm_size: 2gb
depends_on: [selenium-hub]
environment:
SE_EVENT_BUS_HOST: selenium-hub
SE_EVENT_BUS_PUBLISH_PORT: 4442
SE_EVENT_BUS_SUBSCRIBE_PORT: 4443Point your tests at http://localhost:4444/wd/hub. Grid UI: http://localhost:4444/ui.
3. Session queue tuning
Set SE_SESSION_REQUEST_TIMEOUT=300 and SE_SESSION_RETRY_INTERVAL=5 to eliminate the "no free slots" flakes when CI bursts. Also raise SE_NODE_MAX_SESSIONS to (cpu_count × 1.5) — most teams under-provision here.
4. Kubernetes autoscaling
Use the official Selenium Helm chart with KEDA. It scales browser pods against the session queue length, so idle costs stay low. See the Selenium locators cheat sheet for the test-side complement, and explicit / implicit / fluent waits if you are seeing timeout errors under load.