Skip to content

Commit

Permalink
Remove /dev/shm from docs, defaulting to shm-size
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Jul 13, 2021
1 parent 77db00c commit 3680810
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 73 deletions.
62 changes: 30 additions & 32 deletions README.md
Expand Up @@ -31,9 +31,7 @@ https://www.selenium.dev/support/
1. Start a Docker container with Firefox

``` bash
$ docker run -d -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
# OR
$ docker run -d -p 4444:4444 -p 7900:7900 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
```

2. Point your WebDriver tests to http://localhost:4444 *
Expand All @@ -46,8 +44,8 @@ $ docker run -d -p 4444:4444 -p 7900:7900 -v /dev/shm:/dev/shm selenium/standalo

More details about visualising the container activity, check the [Debugging](#debugging) section.

:point_up: When executing `docker run` for an image that contains a browser please either mount
`-v /dev/shm:/dev/shm` or use the flag `--shm-size=2g` to use the host's shared memory.
:point_up: When executing `docker run` for an image that contains a browser please use
the flag `--shm-size=2g` to use the host's shared memory.

:point_up: Always use a Docker image with a full tag to pin a specific browser and Grid version.
See [Tagging Conventions](https://github.com/SeleniumHQ/docker-selenium/wiki/Tagging-Convention) for details.
Expand All @@ -60,17 +58,17 @@ ___

![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png) Firefox
``` bash
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
```

![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_24x24.png) Chrome
``` bash
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
```

![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_24x24.png) Microsoft Edge
``` bash
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-edge:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-edge:4.0.0-rc-1-prerelease-20210618
```

_Note: Only one Standalone container can run on port_ `4444` _at the same time._
Expand All @@ -89,19 +87,19 @@ A Docker [network](https://docs.docker.com/engine/reference/commandline/network_
$ docker network create grid
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
-v /dev/shm:/dev/shm \
selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
-v /dev/shm:/dev/shm \
selenium/node-edge:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
--shm-size="2g" \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
-v /dev/shm:/dev/shm \
selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
```

Expand All @@ -123,34 +121,34 @@ $ docker run -d -p 4442-4444:4442-4444 --name selenium-hub selenium/hub:4.0.0-rc

Node Chrome - Machine/VM 2
``` bash
$ docker run -d -p 5555:5555
$ docker run -d -p 5555:5555 \
--shm-size="2g" \
-e SE_EVENT_BUS_HOST=<ip-from-machine-1> \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
-e SE_NODE_HOST=<ip-from-machine-2> \
-v /dev/shm:/dev/shm \
selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
```

Node Edge - Machine/VM 3
``` bash
$ docker run -d -p 5555:5555
$ docker run -d -p 5555:5555 \
--shm-size="2g" \
-e SE_EVENT_BUS_HOST=<ip-from-machine-1> \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
-e SE_NODE_HOST=<ip-from-machine-3> \
-v /dev/shm:/dev/shm \
selenium/node-edge:4.0.0-rc-1-prerelease-20210618
```

Node Firefox - Machine/VM 4
``` bash
$ docker run -d -p 5555:5555
$ docker run -d -p 5555:5555 \
--shm-size="2g" \
-e SE_EVENT_BUS_HOST=<ip-from-machine-1> \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
-e SE_NODE_HOST=<ip-from-machine-4> \
-v /dev/shm:/dev/shm \
selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
```

Expand Down Expand Up @@ -209,7 +207,7 @@ This example shows how to start the containers manually:

``` bash
$ docker network create grid
$ docker run -d -p 4444:4444 -p 6900:5900 --net grid --name selenium -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 -p 6900:5900 --net grid --name selenium --shm-size="2g" selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid --name video -v /tmp/videos:/videos selenium/video:ffmpeg-4.3.1-20210618
# Run your tests
$ docker stop video && docker rm video
Expand Down Expand Up @@ -376,7 +374,7 @@ variables.
Here is an example with the default values of these environment variables:

```bash
$ docker run -d --e SE_EVENT_BUS_HOST=<event_bus_ip|event_bus_name> -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -v /dev/shm:/dev/shm selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d -e SE_EVENT_BUS_HOST=<event_bus_ip|event_bus_name> -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 --shm-size="2g" selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
```

### Setting Screen Resolution
Expand Down Expand Up @@ -421,7 +419,7 @@ To avoid starting the server you can set the `START_XVFB` environment variable t
(or any other value than `true`), for example:

``` bash
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e START_XVFB=false -v /dev/shm:/dev/shm selenium/node-chrome
$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e START_XVFB=false --shm-size="2g" selenium/node-chrome
```

For more information, see this GitHub [issue](https://github.com/SeleniumHQ/docker-selenium/issues/567).
Expand Down Expand Up @@ -513,9 +511,9 @@ $ docker run -d -p 4444:4444 --net grid --name selenium-hub \
--health-cmd='/opt/bin/check-grid.sh --host 0.0.0.0 --port 4444' \
--health-interval=15s --health-timeout=30s --health-retries=5 \
selenium/hub:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-edge:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e HUB_HOST=selenium-hub --shm-size="2g" selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e HUB_HOST=selenium-hub --shm-size="2g" selenium/node-edge:4.0.0-rc-1-prerelease-20210618
$ docker run -d --net grid -e HUB_HOST=selenium-hub --shm-size="2g" selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
```
**Note:** The `\` line delimiter won't work on Windows based terminals, try either `^` or a backtick.

Expand Down Expand Up @@ -581,9 +579,9 @@ You can override it with the `VNC_PORT` environment variable in case you want to

Here is an example with the standalone images, the same concept applies to the node images.
``` bash
$ docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 -p 5901:5900 -v /dev/shm:/dev/shm selenium/standalone-edge:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4445:4444 -p 5902:5900 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 -p 5900:5900 --shm-size="2g" selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 -p 5901:5900 --shm-size="2g" selenium/standalone-edge:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4445:4444 -p 5902:5900 --shm-size="2g" selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
```

Then, you would use in your VNC client:
Expand Down Expand Up @@ -616,9 +614,9 @@ Similarly to the previous section, feel free to map port 7900 to any free extern

Here is an example with the standalone images, the same concept applies to the node images.
``` bash
$ docker run -d -p 4444:4444 -p 7900:7900 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 -p 7901:7900 -v /dev/shm:/dev/shm selenium/standalone-edge:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4445:4444 -p 7902:7900 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4444:4444 -p 7901:7900 --shm-size="2g" selenium/standalone-edge:4.0.0-rc-1-prerelease-20210618
$ docker run -d -p 4445:4444 -p 7902:7900 --shm-size="2g" selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
```

Then, you would use in your browser:
Expand All @@ -642,13 +640,13 @@ You can increase the log output by passing environment variable to the container
SE_OPTS="--log-level FINE"
```

### `-v /dev/shm:/dev/shm` or `--shm-size 2g`
### `--shm-size="2g"`

Why is `-v /dev/shm:/dev/shm` or `--shm-size 2g` necessary?
Why is `--shm-size 2g` necessary?
> This is a known workaround to avoid the browser crashing inside a docker container, here are the documented issues for
[Chrome](https://code.google.com/p/chromium/issues/detail?id=519952) and [Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=1338771#c10).
The shm size of 2gb is arbitrary but known to work well, your specific use case might need a different value, it is recommended
to tune this value according to your needs. Along the examples `-v /dev/shm:/dev/shm` will be used, but both are known to work.
to tune this value according to your needs.


### Headless
Expand Down
9 changes: 3 additions & 6 deletions docker-compose-v2.yml
Expand Up @@ -5,8 +5,7 @@ version: '2'
services:
chrome:
image: selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-hub
environment:
Expand All @@ -18,8 +17,7 @@ services:

edge:
image: selenium/node-edge:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-hub
environment:
Expand All @@ -31,8 +29,7 @@ services:

firefox:
image: selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-hub
environment:
Expand Down
6 changes: 3 additions & 3 deletions docker-compose-v3-full-grid-dev.yml
Expand Up @@ -82,9 +82,9 @@ services:

chrome:
image: selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
shm_size: 2gb
volumes:
- ./selenium_server_deploy.jar:/opt/selenium/selenium-server.jar
- /dev/shm:/dev/shm
depends_on:
- selenium-event-bus
environment:
Expand All @@ -96,9 +96,9 @@ services:

edge:
image: selenium/node-edge:4.0.0-rc-1-prerelease-20210618
shm_size: 2gb
volumes:
- ./selenium_server_deploy.jar:/opt/selenium/selenium-server.jar
- /dev/shm:/dev/shm
depends_on:
- selenium-event-bus
environment:
Expand All @@ -110,9 +110,9 @@ services:

firefox:
image: selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
shm_size: 2gb
volumes:
- ./selenium_server_deploy.jar:/opt/selenium/selenium-server.jar
- /dev/shm:/dev/shm
depends_on:
- selenium-event-bus
environment:
Expand Down
9 changes: 3 additions & 6 deletions docker-compose-v3-full-grid-swarm.yml
Expand Up @@ -8,8 +8,7 @@ version: '3.7'
services:
chrome:
image: selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand All @@ -20,8 +19,7 @@ services:

edge:
image: selenium/node-edge:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand All @@ -32,8 +30,7 @@ services:

firefox:
image: selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand Down
9 changes: 3 additions & 6 deletions docker-compose-v3-full-grid.yml
Expand Up @@ -72,8 +72,7 @@ services:

chrome:
image: selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-event-bus
environment:
Expand All @@ -85,8 +84,7 @@ services:

edge:
image: selenium/node-edge:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-event-bus
environment:
Expand All @@ -98,8 +96,7 @@ services:

firefox:
image: selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-event-bus
environment:
Expand Down
9 changes: 3 additions & 6 deletions docker-compose-v3-swarm.yml
Expand Up @@ -8,8 +8,7 @@ version: '3.7'
services:
chrome:
image: selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand All @@ -20,8 +19,7 @@ services:

edge:
image: selenium/node-edge:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand All @@ -32,8 +30,7 @@ services:

firefox:
image: selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand Down
9 changes: 3 additions & 6 deletions docker-compose-v3-video.yml
Expand Up @@ -5,8 +5,7 @@ version: "3"
services:
chrome:
image: selenium/node-chrome:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-hub
environment:
Expand All @@ -18,8 +17,7 @@ services:

edge:
image: selenium/node-edge:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-hub
environment:
Expand All @@ -31,8 +29,7 @@ services:

firefox:
image: selenium/node-firefox:4.0.0-rc-1-prerelease-20210618
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- selenium-hub
environment:
Expand Down

0 comments on commit 3680810

Please sign in to comment.