Selenium Grid 4 supports a 'Dynamic Grid' mode where Docker containers are started on demand for each new session and destroyed upon completion. This can be used in both Standalone and Node roles.
To use Dynamic Grid, you must provide a config.toml file that maps Docker images to browser capabilities and specifies the Docker daemon URI.
Important Configuration Details:
- File Path: In Dynamic Grid images (
standalone-docker or node-docker), you must mount your configuration file to /opt/selenium/docker.toml to avoid conflicts with standard browser container configs. - Docker Daemon URL:
- If mounting
/var/run/docker.sock, use http://127.0.0.1:2375 (the container uses socat internally). - On Windows (without socket mount): Use
http://host.docker.internal:2375. - On macOS (without socket mount): Install
socat and run socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock, then use http://host.docker.internal:2375.
- Environment Variable: If you name your config file something other than
docker.toml, set SE_NODE_DOCKER_CONFIG_FILENAME to your filename.
[docker]
# Mapping between Docker image and capabilities
configs = [
"selenium/standalone-firefox:4.46.0-20260707", '{"browserName": "firefox"}',
"selenium/standalone-chrome:4.46.0-20260707", '{"browserName": "chrome"}',
"selenium/standalone-edge:4.46.0-20260707", '{"browserName": "MicrosoftEdge"}'
]
# List of Docker host configuration keys to pass to browser containers
host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts", "Binds"]
# URL for connecting to the docker daemon
url = "http://127.0.0.1:2375"
# Docker image used for video recording
video-image = "selenium/video:ffmpeg-8.1-20260707"
[server]
# Required if running the node on a separate VM
host = <ip-from-node-machine>
port = <port-from-node-machine>