SoftwareTestPilot
Automation TestingPublished: 11 min read

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.

Avinash Kamble
Founder & QA Engineer at SoftwareTestPilot
Reviewed by Priyanka G.
Share:XLinkedInWhatsApp
Selenium Grid 4 hub-node architecture running in Docker Compose.
Selenium Grid 4 hub-node architecture running in Docker Compose.

Last updated 2026-07-20 · 11 min read · By Avinash Kamble, reviewed by Priyanka G.

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.yml for hub + Chrome + Firefox.
  • Session queue tuning that eliminates the "no free slots" flakes.
  • Kubernetes autoscaling via KEDA + the Selenium chart.

1. Pick a topology

TopologyWhen to use
StandaloneLocal dev, 1 machine, no scale.
Hub & NodeSmall teams, <100 parallel sessions.
Fully DistributedEnterprise, 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: 4443

Point 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.

Frequently asked questions

1.Do I still need a Selenium Grid in the Playwright era?
If your automation is Java + Selenium 4 and you need cross-browser at scale (Chrome, Firefox, Edge, Safari), yes. Playwright covers Chromium/Firefox/WebKit but not the legacy Selenium stacks many enterprises still ship on.
2.Docker or Kubernetes?
Start on Docker Compose for <20 parallel sessions. Move to Kubernetes when you need burst capacity or run multi-tenant.
3.How do I record videos?
Add the selenium/video image sidecar to each browser node and mount a volume for the mp4 output.
4.Chromedriver mismatch errors?
Selenium 4.11+ auto-manages drivers via Selenium Manager — remove your webdriver-manager code and let the grid handle it.
Keep going

Practice these questions

Work through 300+ Selenium questions with Java code snippets, Selenium 4, Grid, framework patterns and CI/CD scenarios.

Found this useful?
Share:XLinkedInWhatsApp

Was this article helpful?

Cluster · Selenium

More from Selenium Advanced (Grid, Docker)

Selenium Grid, Docker, parallelism, CDP, cloud runs.

Pillar guide · 2 articles
More in this cluster
From the Selenium pillar

Keep building your QA edge

Practice these questions live

Rehearse with an AI QA interviewer that scores your answers in real time.

Start a Free AI Mock Interview →

Continue reading

Topic mapConcepts · Tools · People · Standards

Related concepts, tools & standards around Automation Testing

A quick reference of the people, companies, frameworks and technologies most often mentioned alongside Automation Testing in real QA teams — useful when you're mapping a learning path, preparing for interviews, or scoping a new project.

Core testing concepts
Explicit vs Implicit WaitsPageFactoryTest PyramidShift-Left TestingBehavior-Driven DevelopmentTest-Driven DevelopmentPage Object ModelContract TestingExploratory TestingRisk-Based Testing
Testing tools
Programming languages
JavaPythonJavaScriptTypeScriptC#SQL
Certifications worth knowing
ISTQB Foundation LevelISTQB Advanced — Test AnalystISTQB Agile TesterCertified Selenium ProfessionalAWS Certified DevOps EngineerCertified ScrumMaster (CSM)
Companies hiring for this skill
GoogleMicrosoftAmazonMetaNetflixAtlassianThoughtWorksInfosysTCSWipro

Discussion

Ask a question, share your experience, or correct us. Be kind — real people are reading.

Join the QA Community

Connect with fellow testers, share job leads, and get career advice.

Premium QA Resources

Stop Reinventing the Wheel. Upgrade Your QA Arsenal.

Take your testing skills from beginner to Lead Engineer. Supercharge your daily workflow with our premium digital resources.

  • Ready-to-use testing strategy templates
  • Advanced API & UI automation guides
  • ⏱️ Save 10+ hours a week on test planning
4.9/5 rating
Explore All Products

⭐⭐⭐⭐⭐ Trusted by 1,000+ Software Test Pilots • Instant Access