Skip to content

Commit 0f4abff

Browse files
committed
Updating README to highlight the importance of using -v /dev/shm:/dev/shm
1 parent 0db218e commit 0f4abff

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,44 @@ The project is made possible by volunteer contributors who have put in thousands
1212
[Travis CI](https://travis-ci.org/SeleniumHQ/docker-selenium)
1313

1414
Images included:
15-
- __selenium/base__: Base image which includes Java runtime and Selenium JAR file
16-
- __selenium/hub__: Image for running a Selenium Grid Hub
17-
- __selenium/node-base__: Base image for Selenium Grid Nodes which includes a virtual desktop environment and VNC support
18-
- __selenium/node-chrome__: Selenium node with Chrome installed, needs to be connected to a Selenium Grid Hub
19-
- __selenium/node-firefox__: Selenium node with Firefox installed, needs to be connected to a Selenium Grid Hub
20-
- __selenium/standalone-chrome__: Selenium standalone with Chrome installed
21-
- __selenium/standalone-firefox__: Selenium standalone with Firefox installed
22-
- __selenium/standalone-chrome-debug__: Selenium standalone with Chrome installed and runs a VNC server
23-
- __selenium/standalone-firefox-debug__: Selenium standalone with Firefox installed and runs a VNC server
24-
- __selenium/node-chrome-debug__: Selenium node with Chrome installed and runs a VNC server, needs to be connected to a Selenium Grid Hub
25-
- __selenium/node-firefox-debug__: Selenium node with Firefox installed and runs a VNC server, needs to be connected to a Selenium Grid Hub
15+
- __selenium/base__: Base image which includes Java runtime and Selenium Server JAR file
16+
- __selenium/hub__: Image for running a Grid Hub
17+
- __selenium/node-base__: Base image for Grid Nodes which includes a virtual desktop environment
18+
- __selenium/node-chrome__: Grid Node with Chrome installed, needs to be connected to a Grid Hub
19+
- __selenium/node-firefox__: Grid Node with Firefox installed, needs to be connected to a Grid Hub
20+
- __selenium/node-chrome-debug__: Grid Node with Chrome installed and runs a VNC server, needs to be connected to a Grid Hub
21+
- __selenium/node-firefox-debug__: Grid Node with Firefox installed and runs a VNC server, needs to be connected to a Grid Hub
22+
- __selenium/standalone-chrome__: Selenium Standalone with Chrome installed
23+
- __selenium/standalone-firefox__: Selenium Standalone with Firefox installed
24+
- __selenium/standalone-chrome-debug__: Selenium Standalone with Chrome installed and runs a VNC server
25+
- __selenium/standalone-firefox-debug__: Selenium Standalone with Firefox installed and runs a VNC server
2626

2727
##
2828

2929
## Running the images
30+
:exclamation: When executing `docker run` for an image with Chrome or Firefox please either mount `-v /dev/shm:/dev/shm` or use the flag `--shm-size=2g` to use the host's shared memory.
3031

31-
When executing docker run for an image with chrome browser please add volume mount `-v /dev/shm:/dev/shm` to use the host's shared memory.
32-
32+
Chrome
3333
``` bash
3434
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.8.1-bohrium
35+
#OR
36+
$ docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome:3.8.1-bohrium
3537
```
36-
37-
This is a workaround to node-chrome crash in docker container issue: https://code.google.com/p/chromium/issues/detail?id=519952
38-
39-
When executing docker run for an image with firefox browser please set shm-size to 2g.
40-
38+
Firefox
4139
``` bash
40+
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:3.8.1-bohrium
41+
#OR
4242
$ docker run -d -p 4444:4444 --shm-size 2g selenium/standalone-firefox:3.8.1-bohrium
4343
```
44-
45-
This is a workaround to node-firefox crash in docker container issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1338771#c10
44+
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.
4645

4746

4847
### Standalone Chrome and Firefox
4948

5049
``` bash
51-
$ docker run -d -p 4444:4444 selenium/standalone-chrome:3.8.1-bohrium
50+
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.8.1-bohrium
5251
# OR
53-
$ docker run -d -p 4444:4444 selenium/standalone-firefox:3.8.1-bohrium
52+
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:3.8.1-bohrium
5453
```
5554

5655
_Note: Only one standalone image can run on port_ `4444` _at a time._
@@ -61,8 +60,8 @@ To inspect visually what the browser is doing use the `standalone-chrome-debug`
6160

6261
``` bash
6362
$ docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.8.1-bohrium
64-
$ docker run -d --link selenium-hub:hub selenium/node-chrome:3.8.1-bohrium
65-
$ docker run -d --link selenium-hub:hub selenium/node-firefox:3.8.1-bohrium
63+
$ docker run -d --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome:3.8.1-bohrium
64+
$ docker run -d --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-firefox:3.8.1-bohrium
6665
```
6766

6867
## Configuring the containers
@@ -89,7 +88,7 @@ You can pass `HUB_PORT_4444_TCP_ADDR` and `HUB_PORT_4444_TCP_PORT` options to pr
8988

9089
``` bash
9190
$ docker run -d -p 4444:4444 -e HUB_PORT_4444_TCP_ADDR=10.10.1.10 -e HUB_PORT_4444_TCP_PORT=4444 \
92-
--name selenium-hub selenium/hub:3.8.1-bohrium
91+
--name selenium-hub selenium/node-chrome:3.8.1-bohrium
9392
```
9493

9594
## Building the images
@@ -116,6 +115,7 @@ _Note: Omitting_ `VERSION=local` _will build the images with the current version
116115
$ docker run -d --name selenium-hub -p 4444:4444 selenium/hub:3.8.1-bohrium
117116
$ CH=$(docker run --rm --name=ch \
118117
--link selenium-hub:hub -v /e2e/uploads:/e2e/uploads \
118+
-v /dev/shm:/dev/shm \
119119
selenium/node-chrome:3.8.1-bohrium)
120120
```
121121

@@ -129,41 +129,41 @@ This command line is the same as for Chrome. Remember that the Selenium running
129129
$ docker run -d --name selenium-hub -p 4444:4444 selenium/hub:3.8.1-bohrium
130130
$ FF=$(docker run --rm --name=fx \
131131
--link selenium-hub:hub -v /e2e/uploads:/e2e/uploads \
132+
-v /dev/shm:/dev/shm \
132133
selenium/node-firefox:3.8.1-bohrium)
133134
```
134135

135136
_Note: Since a Docker container is not meant to preserve state and spawning a new one takes less than 3 seconds you will likely want to remove containers after each end-to-end test with_ `--rm` _command. You need to think of your Docker containers as single processes, not as running virtual machines, in case you are familiar with [Vagrant](https://www.vagrantup.com/)._
136137

137138
## Debugging
138139

139-
In the event you wish to visually see what the browser is doing you will want to run the `debug` variant of node or standalone images. A VNC server will run on port 5900. You are free to map that to any free external port that you wish. Example: <port4VNC>: 5900) you will only be able to run 1 node per port so if you wish to include a second node, or more, you will have to use different ports, the 5900 as the internal port will have to remain the same though as thats the VNC service on the node. The second example below shows how to run multiple nodes and with different VNC ports open:
140+
In the event you wish to visually see what the browser is doing you will want to run the `debug` variant of node or standalone images. A VNC server will run on port 5900. You are free to map that to any free external port that you wish. Keep in mind that you will only be able to run one node per port so if you wish to include a second node, or more, you will have to use different ports, the 5900 as the internal port will have to remain the same though as thats the VNC service on the node. The second example below shows how to run multiple nodes and with different VNC ports open:
140141
``` bash
141-
$ docker run -d -P -p <port4VNC>:5900 --link selenium-hub:hub selenium/node-chrome-debug:3.8.1-bohrium
142-
$ docker run -d -P -p <port4VNC>:5900 --link selenium-hub:hub selenium/node-firefox-debug:3.8.1-bohrium
142+
$ docker run -d -P -p <port4VNC>:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome-debug:3.8.1-bohrium
143+
$ docker run -d -P -p <port4VNC>:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-firefox-debug:3.8.1-bohrium
143144
```
144145
e.g.:
145146
``` bash
146-
$ docker run -d -P -p 5900:5900 --link selenium-hub:hub selenium/node-chrome-debug:3.8.1-bohrium
147-
$ docker run -d -P -p 5901:5900 --link selenium-hub:hub selenium/node-firefox-debug:3.8.1-bohrium
147+
$ docker run -d -P -p 5900:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome-debug:3.8.1-bohrium
148+
$ docker run -d -P -p 5901:5900 --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-firefox-debug:3.8.1-bohrium
148149
```
149-
150150
to connect to the Chrome node on 5900 and the Firefox node on 5901 (assuming those node are free, and reachable).
151151

152152
And for standalone:
153153
``` bash
154-
$ docker run -d -p 4444:4444 -p <port4VNC>:5900 selenium/standalone-chrome-debug:3.8.1-bohrium
154+
$ docker run -d -p 4444:4444 -p <port4VNC>:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.8.1-bohrium
155155
# OR
156-
$ docker run -d -p 4444:4444 -p <port4VNC>:5900 selenium/standalone-firefox-debug:3.8.1-bohrium
156+
$ docker run -d -p 4444:4444 -p <port4VNC>:5900 -v /dev/shm:/dev/shm selenium/standalone-firefox-debug:3.8.1-bohrium
157157
```
158158
or
159159
``` bash
160-
$ docker run -d -p 4444:4444 -p 5900:5900 selenium/standalone-chrome-debug:3.8.1-bohrium
160+
$ docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.8.1-bohrium
161161
# OR
162-
$ docker run -d -p 4444:4444 -p 5901:5900 selenium/standalone-firefox-debug:3.8.1-bohrium
162+
$ docker run -d -p 4444:4444 -p 5901:5900 -v /dev/shm:/dev/shm selenium/standalone-firefox-debug:3.8.1-bohrium
163163
```
164164

165165
You can acquire the port that the VNC server is exposed to by running:
166-
(In this case our port mapping looks like 49338:5900 for our node)
166+
(Assuming that we mapped the ports like this: 49338:5900)
167167
``` bash
168168
$ docker port <container-name|container-id> 5900
169169
#=> 0.0.0.0:49338

0 commit comments

Comments
 (0)