Setting up Grid manually is painful. Download the JAR. Install three browsers. Install matching drivers. Start the Hub. Start each Node. Something crashes. Start over. Docker eliminates all of this. One YAML file. One command. Full Grid with Chrome, Firefox, and Edge — running in seconds.
| Manual Grid Setup | Docker Grid Setup |
|---|---|
| Download Selenium Server JAR manually | One docker-compose.yml file — version controlled |
| Install Chrome, Firefox, Edge on the machine | Browsers + drivers pre-packaged in images |
| Install matching ChromeDriver, GeckoDriver, etc. | No manual installation of anything |
| Start Hub, then each Node separately | One command: docker compose up -d |
| Browser updates break driver compatibility | Pin image versions — same everywhere |
| "Works on my machine, not on CI" | Same setup on laptop, CI, production |
# docker-compose-grid.yml
version: '3'
services:
selenium-hub:
image: selenium/hub:4.18.1
container_name: selenium-hub
ports:
- "4444:4444"
chrome-node:
image: selenium/node-chrome:4.18.1
container_name: chrome-node
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
- SE_NODE_OVERRIDE_MAX_SESSIONS=true
shm_size: '2g'
firefox-node:
image: selenium/node-firefox:4.18.1
container_name: firefox-node
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
- SE_NODE_OVERRIDE_MAX_SESSIONS=true
shm_size: '2g'
edge-node:
image: selenium/node-edge:4.18.1
container_name: edge-node
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
- SE_NODE_OVERRIDE_MAX_SESSIONS=true
shm_size: '2g'# Start the entire Grid
docker compose -f docker-compose-grid.yml up -d
# Check all containers are running
docker compose -f docker-compose-grid.yml ps
# Open the dashboard
# http://localhost:4444/ui
# Need more Chrome capacity? Scale it up
docker compose -f docker-compose-grid.yml up -d --scale chrome-node=3
# Check logs if something is wrong
docker compose -f docker-compose-grid.yml logs chrome-node
# Done? Tear it all down
docker compose -f docker-compose-grid.yml downThe shm_size: '2g' setting is critical. Chrome uses shared memory for rendering. Without it, Chrome crashes inside Docker with cryptic errors. Every Docker Selenium setup must have this. Don't skip it.
| Variable | What It Does |
|---|---|
| SE_EVENT_BUS_HOST | Tells the Node where to find the Hub |
| SE_EVENT_BUS_PUBLISH_PORT | Port for publishing events (always 4442) |
| SE_EVENT_BUS_SUBSCRIBE_PORT | Port for subscribing to events (always 4443) |
| SE_NODE_MAX_SESSIONS | Max parallel browser sessions per node |
| SE_NODE_OVERRIDE_MAX_SESSIONS | Allows overriding the default session limit |
SE_NODE_MAX_SESSIONS=4 means each node can run 4 browsers simultaneously. With 3 Chrome nodes at 4 sessions each, you get 12 Chrome browsers running in parallel. That's 12 tests executing at the same time.
Q: How do you set up Selenium Grid in your project?
A: We use Docker Compose. Our docker-compose-grid.yml defines a Hub and three browser nodes — Chrome, Firefox, and Edge. We start it with "docker compose up -d" and tests connect via RemoteWebDriver to http://localhost:4444. Each node supports 4 parallel sessions. For CI/CD, Jenkins starts the Grid before test execution and tears it down after. We pin the Selenium Docker image version (like 4.18.1) to ensure consistency across environments.
Key Point: Docker Compose + Selenium Grid = one YAML file, one command, full multi-browser test infrastructure.