Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit f7632e0

Browse files
Add Swarm documentation (#405)
Workaround described in #236
1 parent a50951b commit f7632e0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/docker-compose.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,42 @@ You can now run your tests by using the `--seleniumUrl="http://localhost:4444/wd
3434
However if your web application under test is running in localhost, e.g. `--appHost=localhost` or is publicly not accessible
3535
you should instead either dockerize your application as shown in the example [adwords_mock](https://github.com/elgalu/google_adwords_mock) within the [docker-compose-tests.yml][]. Its there shown as another [service](https://docs.docker.com/compose/compose-file/#/service-configuration-reference). Another option (if you don't want to dockerize your app yet) is to somehow replace `--appHost=localhost` with `--appHost=d.host.loc.dev` in the config file of your testing framework. The string `d.host.loc.dev` is a place holder inside the docker container that points to the IP of your localhost.
3636

37+
## Docker Swarm mode
38+
You might get the following error if you try to run a `SELENIUM_NODE` as part of a Swarm stack:
39+
```
40+
$ docker stack deploy selenium
41+
Updating service selenium_selenium-chrome (id: joru9fw8xej2imcrvgblcrc85)
42+
failed to create service selenium_selenium-chrome: Error response from daemon: rpc error: code = InvalidArgument desc = expanding env failed: expanding env "SELENIUM_NODE_HOST={{CONTAINER_IP}}": template: expansion:1: function "CONTAINER_IP" not defined
43+
```
44+
Thanks to https://github.com/elgalu/docker-selenium/issues/236 you just have to update your variable `SELENIUM_NODE_HOST` to `{{__CONTAINER_IP__}}`.
45+
Example in a `docker-compose file`:
46+
```
47+
selenium-firefox:
48+
image: elgalu/selenium
49+
depends_on:
50+
- hub
51+
volumes:
52+
- /dev/shm:/dev/shm
53+
deploy:
54+
replicas: 3
55+
environment:
56+
- DEBUG=true
57+
- PICK_ALL_RANDOM_PORTS=true
58+
- SELENIUM_HUB_HOST=hub
59+
- SELENIUM_HUB_PORT=4444
60+
- SELENIUM_NODE_HOST={{__CONTAINER_IP__}}
61+
- SCREEN_WIDTH=1300
62+
- SCREEN_HEIGHT=999
63+
- VIDEO=false
64+
- AUDIO=false
65+
- GRID=false
66+
- CHROME=false
67+
- FIREFOX=true
68+
- MAX_INSTANCES=1
69+
- MAX_SESSIONS=1
70+
```
71+
72+
3773
### Cleanup
3874
Once your tests are done you can clean up:
3975

0 commit comments

Comments
 (0)