Skip to content

Commit 71657be

Browse files
Ay0diemol
Ay0
authored andcommitted
README improvements and fixes (#803)
* Missing docker port in REMOTE_HOST example. Issue #799 was partially caused by a missing port in the docker run statement * Added docker-compose example with support for Docker SWARM * added command to start docker in swarm mode
1 parent cf5736d commit 71657be

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

README.md

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Images included:
2424
- __selenium/standalone-chrome-debug__: Selenium Standalone with Chrome installed and runs a VNC server
2525
- __selenium/standalone-firefox-debug__: Selenium Standalone with Firefox installed and runs a VNC server
2626

27-
##
27+
##
2828

2929
## Running the images
3030
: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.
@@ -78,7 +78,7 @@ When you are done using the grid and the containers have exited, the network can
7878
``` bash
7979
# Remove all unused networks
8080
$ docker network prune
81-
# OR
81+
# OR
8282
# Removes the grid network
8383
$ docker network rm grid
8484
```
@@ -146,10 +146,43 @@ services:
146146
147147
To stop the grid and cleanup the created containers, run `docker-compose down`.
148148

149+
##### Version 3 with Swarm support
150+
```yaml
151+
# To start Docker in Swarm mode, you need to run `docker swarm init`
152+
# To deploy the Grid, `docker stack deploy -c docker-compose.yml grid`
153+
# Stop with `docker stack rm grid`
154+
155+
version: '3.7'
156+
157+
services:
158+
hub:
159+
image: selenium/hub:3.14.0-francium
160+
ports:
161+
- "4444:4444"
162+
163+
chrome:
164+
image: selenium/node-chrome:3.14.0-francium
165+
environment:
166+
HUB_HOST: hub
167+
HUB_PORT: 4444
168+
deploy:
169+
replicas: 1
170+
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'
171+
172+
firefox:
173+
image: selenium/node-firefox:3.14.0-francium
174+
environment:
175+
HUB_HOST: hub
176+
HUB_PORT: 4444
177+
deploy:
178+
replicas: 1
179+
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'
180+
```
181+
149182
#### Using `--link`
150183
This option can be used for a single host scenario (hub and nodes running in a single machine), but it is not recommended
151184
for longer term usage since this is a docker [legacy feature](https://docs.docker.com/compose/compose-file/#links).
152-
It could serve you as an option for a proof of concept, and for simplicity it is used in the examples shown from now on.
185+
It could serve you as an option for a proof of concept, and for simplicity it is used in the examples shown from now on.
153186

154187
``` bash
155188
$ docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.14.0-francium
@@ -188,16 +221,16 @@ or `REMOTE_HOST` can be used.
188221
You can pass the `HUB_HOST` and `HUB_PORT` options to provide the hub address to a node when needed.
189222

190223
``` bash
191-
# Assuming a hub was already started
224+
# Assuming a hub was already started on the default port
192225
$ docker run -d -e HUB_HOST=<hub_ip|hub_name> -e HUB_PORT=4444 selenium/node-chrome:3.14.0-francium
193226
```
194227

195228
Some network topologies might prevent the hub to reach the node through the url given at registration time, `REMOTE_HOST`
196-
can be used to supply the hub a url where the node is reachable under your specific network configuration
229+
can be used to supply the hub a url where the node is reachable under your specific network configuration
197230

198231
``` bash
199-
# Assuming a hub was already started
200-
$ docker run -d -e HUB_HOST=<hub_ip|hub_name> -e REMOTE_HOST="http://node_ip|node_name:node_port" selenium/node-firefox:3.14.0-francium
232+
# Assuming a hub was already started on the default port
233+
$ docker run -d -p <node_port>:5555 -e HUB_HOST=<hub_ip|hub_name> -e HUB_PORT=4444 -e REMOTE_HOST="http://<node_ip|node_name>:<node_port>" selenium/node-firefox:3.14.0-francium
201234
```
202235

203236
### Setting Screen Resolution
@@ -214,7 +247,7 @@ By default, each image will only allow one slot per container, which is what we
214247
container resources and variables will be used for that browser, and this helps to have more stable tests.
215248

216249
Nevertheless, if you would like to have more slots per node, this can be configured via environment variables with the
217-
environment variable `NODE_MAX_INSTANCES`. For example, a Firefox node with 5 slots:
250+
environment variable `NODE_MAX_INSTANCES`. For example, a Firefox node with 5 slots:
218251

219252
``` bash
220253
# Assuming a hub was already started
@@ -303,7 +336,7 @@ A Grid that is ready, composed by a hub and a node, could look like this:
303336
}
304337
```
305338

306-
The `"ready": true` value indicates that the Grid is ready to receive requests. This status can be polled through a
339+
The `"ready": true` value indicates that the Grid is ready to receive requests. This status can be polled through a
307340
script before running any test, or it can be added as a [HEALTHCHECK](https://docs.docker.com/engine/reference/run/#healthcheck)
308341
when the docker container is started.
309342

@@ -359,15 +392,15 @@ done
359392
exec $cmd
360393
```
361394
**Note:** If needed, replace `localhost` and `4444` for the correct values in your environment. Also, this script is polling indefinitely, you might want
362-
to tweak it and establish a timeout.
395+
to tweak it and establish a timeout.
363396

364397
Let's say that the normal command to execute your tests is `mvn clean test`. Here is a way to use the above script and execute your tests:
365398

366399
```bash
367400
$ ./wait-for-grid.sh mvn clean test
368401
```
369402

370-
Like this, the script will poll until the Grid is ready, and then your tests will start.
403+
Like this, the script will poll until the Grid is ready, and then your tests will start.
371404

372405
## Debugging
373406

0 commit comments

Comments
 (0)