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

Commit

Permalink
Upgrade Selenium 2.51.0, FF 44.0.1, closes #58 through --no-sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
elgalu committed Feb 9, 2016
1 parent d68fc2f commit 8c1ddf7
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 44 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ Note image ids also change after scm-source.json has being updated which trigger
###### To get container versions
docker exec grid versions

## 2.51.0a (2016-02-09)
+ Upgrade Selenium to 2.51.0
+ Upgrade Firefox to 44.0.1
+ Upgrade BrowserStack to 4.7
+ Allow Chrome `--no-sandbox` mode through `$CHROME_ARGS`
+ Image tag details:
+ Selenium: v2.51.0 (1af067d)
+ Chrome stable: 48.0.2564.103
+ Firefox stable: 44.0.1
+ Chromedriver: 2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a)
+ Java: 1.8.0_72-internal OpenJDK 64-Bit 1.8.0_72-b15
+ Timezone: Europe/Berlin
+ Built with: Docker version 1.10.0, build 590d5108
+ FROM ubuntu:xenial-20160125
+ Python: 2.7.11
+ Sauce Connect 4.3.13, build 1877 d9e5947
+ BrowserStack Local version 4.7
+ Image ID: TBD
+ Digest: sha256:TBD

## 2.50.1b (2016-02-04)
+ Upgrade Chrome to 48.0.2564.103 and log chores
+ Image tag details:
Expand Down
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ RUN cd /tmp \
# FF_LANG can be either en-US // de // fr and so on
# Regarding the pip packages, see released versions at:
# https://github.com/mozilla/mozdownload/releases
ENV FF_VER="44.0" \
ENV FF_VER="44.0.1" \
FF_LANG="en-US" \
FF_PLATFORM="linux-x86_64" \
FF_BASE_URL="https://archive.mozilla.org/pub" \
Expand Down Expand Up @@ -621,8 +621,8 @@ USER ${NORMAL_USER}
#==========
# Selenium
#==========
ENV SEL_MAJOR_MINOR_VER 2.50
ENV SEL_PATCH_LEVEL_VER 1
ENV SEL_MAJOR_MINOR_VER 2.51
ENV SEL_PATCH_LEVEL_VER 0
RUN mkdir -p ${SEL_HOME} \
&& export SELBASE="http://selenium-release.storage.googleapis.com" \
&& export SELPATH="${SEL_MAJOR_MINOR_VER}/selenium-server-standalone-${SEL_MAJOR_MINOR_VER}.${SEL_PATCH_LEVEL_VER}.jar" \
Expand Down Expand Up @@ -710,6 +710,10 @@ RUN gdebi --non-interactive ${CHROME_BASE_DEB_PATH}-stable_current_amd64.deb \
# && mv ${CHROME_BASE_DEB_PATH}-unstable_current_amd64.deb \
# ${CHROME_BASE_DEB_PATH}-unstable_${CH_UNSTABLE_VER}_amd64.deb \

# Specifically to have a wrapper for /opt/google/chrome/google-chrome
RUN mv /opt/google/chrome/google-chrome /opt/google/chrome/google-chrome-base
ADD selenium-node-chrome/opt /opt

#==============
# Chromedriver
#==============
Expand Down Expand Up @@ -835,6 +839,10 @@ ENV FIREFOX_VERSION="${FF_VER}" \
# Selenium additional params:
SELENIUM_HUB_PARAMS="" \
SELENIUM_NODE_PARAMS="" \
# To taggle issue #58 see https://goo.gl/fz6RTu
CHROME_ARGS="--no-sandbox" \
# SELENIUM_NODE_CHROME_PARAMS='-Dselenium.chrome.args="--no-sandbox"' \
# WEBDRIVER_NODE_CHROME_PARAMS='-Dwebdriver.chrome.args="--no-sandbox"' \
# Selenium capabilities descriptive (to avoid opera/ie warnings)
# docs at https://code.google.com/p/selenium/wiki/Grid2
MAX_INSTANCES=1 \
Expand Down
43 changes: 30 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Note SeleniumHQ/docker-selenium project is more useful for building selenium gri

In general add `sudo` only if needed in your environment and `--privileged` or `-v /dev/shm:/dev/shm` if you really need it like when [Chrome crashes](https://github.com/elgalu/docker-selenium/issues/20) during your high gpu intensive tests.

docker pull elgalu/selenium:2.50.1b
docker pull elgalu/selenium:2.51.0a

docker run --rm --name=grid -p 4444:24444 -p 5920:25900 \
-v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/selenium:2.50.1b
-v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/selenium:2.51.0a

Make sure `docker run` finishes via active wait with below command. Note `grid` is the name of the container:

Expand Down Expand Up @@ -64,12 +64,12 @@ Supervisor exposes an http server but is not enough to bind the ports via `docke
### Screen size
You can set a custom screen size at docker run time by providing `SCREEN_WIDTH` and `SCREEN_HEIGHT` environment variables:

docker pull elgalu/selenium:2.50.1b
docker pull elgalu/selenium:2.51.0a

docker run -d --name=grid -p 4444:24444 -p 5920:25900 \
-v /dev/shm:/dev/shm -e VNC_PASSWORD=hola \
-e SCREEN_WIDTH=1920 -e SCREEN_HEIGHT=1480 \
elgalu/selenium:2.50.1b
elgalu/selenium:2.51.0a

docker exec grid wait_all_done 10s

Expand Down Expand Up @@ -123,7 +123,7 @@ You need to pass the environment variable `-e NOVNC=true` in order to start the

docker run --rm --name=grid -p 4444:24444 -p 5920:25900 \
-p 6080:26080 -e NOVNC=true \
elgalu/selenium:2.50.1b
elgalu/selenium:2.51.0a

If the VNC password was randomly generated find out with

Expand All @@ -147,11 +147,28 @@ docker exec grid sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512
```

## Chrome not reachable or timeout after 60 secs
In CentOS is necessary to disable [sandbox mode](http://www.chromium.org/developers/design-documents/sandbox) through [--no-sandbox](http://peter.sh/experiments/chromium-command-line-switches/#no-sandbox) example client implementation:
In CentOS and apparently since docker 1.10.0 is necessary to disable [sandbox mode](http://www.chromium.org/developers/design-documents/sandbox) through [--no-sandbox](http://peter.sh/experiments/chromium-command-line-switches/#no-sandbox) example client implementation.

The error comes along with this message while starting Chrome:

> Failed to move to new namespace: PID namespaces supported. Network namespace supported, but failed: errno = Operation not permitted
### No Sandbox

ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");

In Protrator

capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox'],
},
},

However this is now the default of this image, see `CHROME_ARGS="--no-sandbox"` in the Dockerfile so don't be surprised to see the "Stability and security will suffer" banner when opening Chrome inside the container.

## Security

A file [scm-source.json](./scm-source.json) is included at the root directory of the generated image with information that helps to comply with auditing requirements to trace the creation of this docker image.
Expand All @@ -173,9 +190,9 @@ There are also additional steps you can take to ensure you're using the correct

You can simply verify that image id is indeed the correct one.

# e.g. full image id for tag 2.50.1b
# e.g. full image id for tag 2.51.0a
export IMGID="<<Please see CHANGELOG.md>>"
if docker inspect -f='{{.Id}}' elgalu/selenium:2.50.1b |grep ${IMGID} &> /dev/null; then
if docker inspect -f='{{.Id}}' elgalu/selenium:2.51.0a |grep ${IMGID} &> /dev/null; then
echo "Image ID tested ok"
else
echo "Image ID doesn't match"
Expand All @@ -185,7 +202,7 @@ You can simply verify that image id is indeed the correct one.

Given docker.io currently allows to push the same tag image twice this represent a security concern but since docker >= 1.6.2 is possible to fetch the digest sha256 instead of the tag so you can be sure you're using the exact same docker image every time:

# e.g. sha256 for tag 2.50.1b
# e.g. sha256 for tag 2.51.0a
export SHA=<<Please see CHANGELOG.md>>
docker pull elgalu/selenium@sha256:${SHA}

Expand All @@ -211,7 +228,7 @@ Host machine, terminal 2:
docker run --rm --name=ch -p=4444:24444 \
-e SCREEN_WIDTH -e SCREEN_HEIGHT -e XE_DISP_NUM \
-v /tmp/.X11-unix/X${XE_DISP_NUM}:/tmp/.X11-unix/X${XE_DISP_NUM} \
elgalu/selenium:2.50.1b
elgalu/selenium:2.51.0a

Now when you run your tests instead of connecting. If docker run fails try `xhost +`

Expand All @@ -233,7 +250,7 @@ ANYPORT=0
REMOTE_DOCKER_SRV=localhost
CONTAINER=$(docker run -d -p=0.0.0.0:${ANYPORT}:22222 -p=0.0.0.0:${ANYPORT}:24444 \
-p=0.0.0.0:${ANYPORT}:25900 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola \
-e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:2.50.1b
-e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:2.51.0a
# -- Option 2.docker run- Running docker on remote docker server like in the cloud
# Useful if the docker server is running in the cloud. Establish free local ports
Expand All @@ -243,7 +260,7 @@ ssh ${REMOTE_DOCKER_SRV} #get into the remote docker provider somehow
# it acts as a jump host so my public key is already on that server
CONTAINER=$(docker run -d -p=0.0.0.0:${ANYPORT}:22222 -e SCREEN_HEIGHT=1110 \
-e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/authorized_keys)" \
elgalu/selenium:2.50.1b
elgalu/selenium:2.51.0a
# -- Common: Wait for the container to start
./host-scripts/wait-docker-selenium.sh grid 7s
Expand Down Expand Up @@ -314,7 +331,7 @@ If you git clone this repo locally, i.e. cd into where the Dockerfile is, you ca
If you prefer to download the final built image from docker you can pull it, personally I always prefer to build them manually except for the base images like Ubuntu 14.04.2:
docker pull elgalu/selenium:2.50.1b
docker pull elgalu/selenium:2.51.0a
#### 2. Use this image
Expand Down
50 changes: 25 additions & 25 deletions READMELeo.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Build

time (docker build -t="elgalu/selenium:2.50.1b" . ;echo $?;beep)
docker run --rm -ti -m 4000M --cpu-quota=0 --name=grid -p=4444:24444 -p=5920:25900 -p=2222:22222 -e DISABLE_ROLLBACK=true -e VIDEO=true -e MEM_JAVA="1024m" -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" -v /dev/shm:/dev/shm elgalu/selenium:2.50.1b
time (docker build -t="elgalu/selenium:2.51.0a" . ;echo $?;beep)
docker run --rm -ti -m 4000M --cpu-quota=0 --name=grid -p=4444:24444 -p=5920:25900 -p=2222:22222 -e DISABLE_ROLLBACK=true -e VIDEO=true -e MEM_JAVA="1024m" -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" -v /dev/shm:/dev/shm elgalu/selenium:2.51.0a

Wait and id

Expand All @@ -16,16 +16,16 @@ Chrome artifact

Commit, rebuild, test and grab image Id

docker inspect -f='{{.Id}}' elgalu/selenium:2.50.1b | xclip -sel clip
docker inspect -f='{{.Id}}' elgalu/selenium:2.51.0a | xclip -sel clip

## Push

docker push elgalu/selenium:2.50.1b ;echo $?;beep
docker push elgalu/selenium:2.51.0a ;echo $?;beep
# grab digest and update CHANGELOG.md
git add CHANGELOG.md && gci "2.50.1b: Update image id and digest"
docker tag -f elgalu/selenium:2.50.1b elgalu/selenium:latest
git add CHANGELOG.md && gci "2.51.0a: Update image id and digest"
docker tag -f elgalu/selenium:2.51.0a elgalu/selenium:latest
docker push elgalu/selenium:latest
git tag 2.50.1b && git tag -f latest && git push && git push --tags -f
git tag 2.51.0a && git tag -f latest && git push && git push --tags -f

Location of binaries, e.g.

Expand All @@ -40,9 +40,9 @@ Push setup, first time only:

Build a grid with extra nodes

docker run --rm --name=grid -p 4444:24444 -p 5920:25900 -v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/selenium:2.50.1b
docker run --rm --name=grid -p 4444:24444 -p 5920:25900 -v /dev/shm:/dev/shm -e VNC_PASSWORD=hola elgalu/selenium:2.51.0a

docker run --rm --name=node -e DISP_N=13 -e SSHD_PORT=22223 -e SUPERVISOR_HTTP_PORT=29003 -e VNC_PORT=25903 -e SELENIUM_NODE_CH_PORT=25330 -e SELENIUM_NODE_FF_PORT=25331 -e GRID=false -e CHROME=true -e FIREFOX=true --net=container:grid elgalu/selenium:2.50.1b
docker run --rm --name=node -e DISP_N=13 -e SSHD_PORT=22223 -e SUPERVISOR_HTTP_PORT=29003 -e VNC_PORT=25903 -e SELENIUM_NODE_CH_PORT=25330 -e SELENIUM_NODE_FF_PORT=25331 -e GRID=false -e CHROME=true -e FIREFOX=true --net=container:grid elgalu/selenium:2.51.0a

See logs

Expand All @@ -69,18 +69,18 @@ List firefox versions via docker exe

## To update image id and digest

docker inspect -f='{{.Id}}' elgalu/selenium:2.50.1b
docker inspect -f='{{.Id}}' elgalu/selenium:2.51.0a
docker images --digests

## Run with shared dir

docker run --rm --name=grid -p=127.0.0.1:4460:24444 -p=127.0.0.1:5910:25900 \
-v /e2e/uploads:/e2e/uploads elgalu/selenium:2.50.1b
-v /e2e/uploads:/e2e/uploads elgalu/selenium:2.51.0a
docker run --rm --name=grid -p=4460:24444 -p=5910:25900 \
-v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) elgalu/selenium:2.50.1b
-v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) elgalu/selenium:2.51.0a


docker run --rm --name=ff -p=127.0.0.1:4461:24444 -p=127.0.0.1:5911:25900 -v /e2e/uploads:/e2e/uploads elgalu/selenium:2.50.1b
docker run --rm --name=ff -p=127.0.0.1:4461:24444 -p=127.0.0.1:5911:25900 -v /e2e/uploads:/e2e/uploads elgalu/selenium:2.51.0a

## Run without shared dir and bind ports to all network interfaces

Expand All @@ -103,11 +103,11 @@ List firefox versions via docker exe
## Run without dir and bind to all interfaces
Note anything after the image will be taken as arguments for the cmd/entrypoint

docker run --rm --name=grid -p=0.0.0.0:8813:8484 -p=0.0.0.0:2222:2222 -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 -e SCREEN_WIDTH=1800 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:2.50.1b
docker run --rm --name=grid -p=0.0.0.0:8813:8484 -p=0.0.0.0:2222:2222 -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 -e SCREEN_WIDTH=1800 -e SCREEN_HEIGHT=1110 -e VNC_PASSWORD=hola -e SSH_AUTH_KEYS="$(cat ~/.ssh/id_rsa.pub)" elgalu/selenium:2.51.0a

docker run --rm --name=grid -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola elgalu/selenium:2.50.1b
docker run --rm --name=grid -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola docker.io/elgalu/selenium:2.50.1b
docker run --rm --name=grid -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 --add-host myserver.dev:172.17.42.1 elgalu/selenium:2.50.1b
docker run --rm --name=grid -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola elgalu/selenium:2.51.0a
docker run --rm --name=grid -p=4470:24444 -p=5920:25900 -e VNC_PASSWORD=hola docker.io/elgalu/selenium:2.51.0a
docker run --rm --name=grid -p=0.0.0.0:4470:24444 -p=0.0.0.0:5920:25900 --add-host myserver.dev:172.17.42.1 elgalu/selenium:2.51.0a

However adding a custom host IP to server-selenium.local (e.g. bsele ssh config) is more work:

Expand All @@ -116,18 +116,18 @@ However adding a custom host IP to server-selenium.local (e.g. bsele ssh config)

vncv localhost:5920 -Scaling=60% &

docker run --rm --name=ff -p=0.0.0.0:4471:24444 -p=0.0.0.0:5921:25900 elgalu/selenium:2.50.1b
docker run --rm --name=ff -p=0.0.0.0:4471:24444 -p=0.0.0.0:5921:25900 elgalu/selenium:2.51.0a

Automatic builds not working for me right now, maybe there is an issue with docker registry v1 vs v2
https://registry.hub.docker.com/u/elgalu/docker-selenium/builds_history/31621/

## Pulling

docker pull registry.hub.docker.com/elgalu/selenium:2.50.1b
docker pull registry.hub.docker.com/elgalu/selenium:2.51.0a

## Pull

docker run -d --name=max -p=0.0.0.0:4411:24444 -p=0.0.0.0:5911:25900 elgalu/selenium:2.50.1b
docker run -d --name=max -p=0.0.0.0:4411:24444 -p=0.0.0.0:5911:25900 elgalu/selenium:2.51.0a

How to connect through vnc (need a vnc client)

Expand Down Expand Up @@ -336,7 +336,7 @@ https://github.com/rogaha/docker-desktop/blob/master/Dockerfile#L38
You can launch a grid only container via environment variables:

docker run --rm --name=hub -p 4444:24444 -p 5930:25900 \
-e CHROME=false -e FIREFOX=false elgalu/selenium:2.50.1b
-e CHROME=false -e FIREFOX=false elgalu/selenium:2.51.0a

The important part above is `-e CHROME=false -e FIREFOX=false` which tells the docker image not run run default chorme and firefox nodes turning the container into a grid-only one.

Expand All @@ -350,7 +350,7 @@ You can lunch a node only container via environment variables:
-e SELENIUM_HUB_PORT=4444 \
-e SELENIUM_NODE_HOST=docker.host \
-e GRID=false -e CHROME=true -e FIREFOX=true \
elgalu/selenium:2.50.1b
elgalu/selenium:2.51.0a

The important part above is `-e GRID=false` which tells the container to be a node-only node, this this case with 2 browsers `-e CHROME=true -e FIREFOX=true` but could be just 1.

Expand All @@ -364,7 +364,7 @@ Start the grid with Chrome and Firefox
-e SELENIUM_NODE_CH_PORT=25010 -e SELENIUM_NODE_FF_PORT=26010 \
-e GRID=true -e CHROME=true -e FIREFOX=true \
-e VNC_PASSWORD=hola -e VNC_PORT=5810 \
-v /dev/shm:/dev/shm elgalu/selenium:2.50.1b
-v /dev/shm:/dev/shm elgalu/selenium:2.51.0a

Add another docker container node with 2 more browsers:

Expand All @@ -374,7 +374,7 @@ Add another docker container node with 2 more browsers:
-e SELENIUM_NODE_CH_PORT=25020 -e SELENIUM_NODE_FF_PORT=26020 \
-e GRID=false -e CHROME=true -e FIREFOX=true \
-e VNC_PASSWORD=hola -e VNC_PORT=5820 \
-v /dev/shm:/dev/shm elgalu/selenium:2.50.1b
-v /dev/shm:/dev/shm elgalu/selenium:2.51.0a

And another

Expand All @@ -384,4 +384,4 @@ And another
-e SELENIUM_NODE_CH_PORT=25030 -e SELENIUM_NODE_FF_PORT=26030 \
-e GRID=false -e CHROME=true -e FIREFOX=true \
-e VNC_PASSWORD=hola -e VNC_PORT=5830 \
-v /dev/shm:/dev/shm elgalu/selenium:2.50.1b
-v /dev/shm:/dev/shm elgalu/selenium:2.51.0a
3 changes: 2 additions & 1 deletion bin/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Exit immediately if a command exits with a non-zero status
# set -e

echo "-- INFO: Available Firefox Versions: ${FIREFOX_VERSIONS}"
# echo "-- INFO: Available Firefox Versions: ${FIREFOX_VERSIONS}"
echo "-- INFO: Available Firefox Versions: ${FIREFOX_VERSION}"

#---------------------
# Fix/extend ENV vars
Expand Down
4 changes: 2 additions & 2 deletions docs/videos.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
### Pull
Pull image

docker pull elgalu/selenium:2.50.1b
docker pull elgalu/selenium:2.51.0a

### Run
Run a new grid

docker run --rm --name=grid -p 4444:24444 -p 5920:25900 \
-v /dev/shm:/dev/shm -e VNC_PASSWORD=hola \
-e VIDEO=true elgalu/selenium:2.50.1b
-e VIDEO=true elgalu/selenium:2.51.0a

### Wait
Wait for the grid to start
Expand Down
1 change: 1 addition & 0 deletions selenium-node-chrome/opt/google/chrome/google-chrome
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exec /opt/google/chrome/google-chrome-base $@ ${CHROME_ARGS}

3 comments on commit 8c1ddf7

@arunbcodes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I am not sure if this is the right place to ask this question. Can you tell me where exactly is the selenium-node-chrome/opt/google/chrome/google-chrome file called and executed? I dont see this being called anywhere.

@elgalu
Copy link
Owner Author

@elgalu elgalu commented on 8c1ddf7 Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! That file is just a wrapper to call the real google-chrome binary so you can inject CHROME_ARGS through docker run ... -e CHROME_ARGS="--no-sandbox --ignore-certificate-errors" for example.

The magic happens here: https://github.com/elgalu/docker-selenium/blob/2.53.0r/Dockerfile#L816

@elgalu
Copy link
Owner Author

@elgalu elgalu commented on 8c1ddf7 Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And google-chrome is called by selenium when running tests in Chrome.

Please sign in to comment.