Selenium
What is Selenium?
Selenium is a browser automation framework. Laradock runs a Selenium WebDriver server in its own container so you can drive real browser tests (Laravel Dusk, Panther, or any WebDriver client) without installing a browser and driver stack on your host.
Start Selenium
- Laradock CLI
- Docker Compose
./laradock start selenium
docker compose up -d selenium
Stop Selenium
- Laradock CLI
- Docker Compose
./laradock stop selenium
docker compose stop selenium
Selenium keeps no data between runs, so there's nothing to preserve or lose here, stopping (or removing) the container just frees the port until you start it again.
Configuration
Selenium's only Laradock-level setting lives in selenium/defaults.env:
| Variable | Default | What it does |
|---|---|---|
SELENIUM_PORT | 4444 | Host port the Selenium WebDriver hub is published on. |
The container also mounts your host's /dev/shm into the container at the same path, browsers (especially Chrome) can run out of shared memory and crash without this.
Connect a WebDriver client
Open http://localhost:4444/wd/hub to confirm the hub is up. Point your WebDriver client (Dusk, Panther, raw Selenium bindings) at that same URL. From inside another Laradock container, use http://selenium:4444/wd/hub instead of localhost.
Watch the browser live (noVNC)
The underlying image (selenium/standalone-chrome) runs a VNC server alongside the browser, so you can literally watch what your tests are doing instead of guessing from a stack trace. It isn't published by default in selenium/compose.yml, add the port mapping yourself:
services:
selenium:
ports:
- "${SELENIUM_PORT}:4444"
- "7900:7900"
Then restart:
- Laradock CLI
- Docker Compose
./laradock restart selenium
docker compose restart selenium
Open http://localhost:7900 in a browser and connect, the default noVNC password is secret. Useful for debugging a test that fails only in CI-like headless conditions.
Use a different browser
Laradock's selenium/Dockerfile is pinned to selenium/standalone-chrome. To test against Firefox instead, point it at the equivalent upstream image:
FROM selenium/standalone-firefox
Then rebuild:
- Laradock CLI
- Docker Compose
./laradock rebuild selenium
docker compose build selenium
Everything else on this page (port, /dev/shm, VNC) works the same regardless of which browser image you use.
Common issues
- Browser crashes mid-test with no clear error. This is almost always
/dev/shmrunning out of space under a heavy test suite; the container already mounts the host's/dev/shm, if you're still hitting this, check available shared memory on your host. - Tests hang waiting for a session. Confirm the container actually started:
./laradock logs selenium. A hub that never reports itself ready will leave WebDriver clients waiting indefinitely. - App under test can't be reached by the browser. The Selenium container needs to reach your app over the Docker network, use a container name (e.g.
nginxorhttp://workspace) in your base test URL, notlocalhost, which inside theseleniumcontainer refers to itself. - Port already in use on your host. Change
SELENIUM_PORTin.envand restart:./laradock restart selenium.
Running Laravel Dusk? See the Dusk documentation for driving it against this hub. New to Laradock? Start at Getting Started.