Docker Community Forums

Share and learn in the Docker community.

Chrome Installation could not be found in docker image based from windows servercore (Cannot find Chrome binary)

Description

Chrome does not seem to be installed even though there are no error messages when running on docker build or it is possible I just don’t know the default installation directory. Please advise on below issue.

Steps to reproduce the issue:

  1. Create DOCKERFILE
  2. build image from DOCKERFILE
  3. run image detached and exposed to port 4444
  4. access local selenium hub (http://localhost:4444/wd/hub)
  5. Create New Session
  6. Unable to find Chrome binary

Describe the results you received:

Output of docker build -t local/selenium_server .

Sending build context to Docker daemon  20.21MB
Step 1/16 : FROM openjdk:windowsservercore-1803
 ---> ff52812f16b8
Step 2/16 : WORKDIR /chromeapp
 ---> Running in 03e46ab92de4
Removing intermediate container 03e46ab92de4
 ---> a6945768be94
Step 3/16 : COPY selenium-server-standalone-3.141.59.jar ./
 ---> 2829e4d18f1d
Step 4/16 : ENV WEBDRIVERS="C:\webdrivers"
 ---> Running in 0d3a66319526
Removing intermediate container 0d3a66319526
 ---> 45f976d2d310
Step 5/16 : RUN iwr "https://chromedriver.storage.googleapis.com/75.0.3770.140/chromedriver_win32.zip" -Proxy "http://111.111.11.111:8080" -OutFile 'C:\chromedriver.zip' -UseBasicParsing;     Expand-Archive C:\chromedriver.zip -DestinationPath $env:WEBDRIVERS;     Remove-Item C:\chromedriver.zip;
 ---> Running in 74b8260fd5a3
Removing intermediate container 74b8260fd5a3
 ---> 29c537954516
Step 6/16 : SHELL ["cmd", "/S", "/C"]
 ---> Running in 6abde371e907
Removing intermediate container 6abde371e907
 ---> 5255118f738f
Step 7/16 : RUN setx /M PATH "%PATH%;%WEBDRIVERS%"
 ---> Running in 8ed25032f606

SUCCESS: Specified value was saved.
Removing intermediate container 8ed25032f606
 ---> 91d4dc1d97a1
Step 8/16 : SHELL ["Powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
 ---> Running in c0f90b546f5d
Removing intermediate container c0f90b546f5d
 ---> e245a906b5eb
Step 9/16 : RUN iwr "https://dl.google.com/chrome/install/75/chrome_installer.exe" -Proxy "http://111.111.11.111:8080" -OutFile 'C:\chrome_installer.exe' -UseBasicParsing;
 ---> Running in 164ae1db40bd
Removing intermediate container 164ae1db40bd
 ---> e42c3ad5322d
Step 10/16 : RUN C:\chrome_installer.exe /silent /install
 ---> Running in 27d6b082b40e
Removing intermediate container 27d6b082b40e
 ---> b745e2aa101b
Step 11/16 : SHELL ["cmd", "/S", "/C"]
 ---> Running in 3e741e384804
Removing intermediate container 3e741e384804
 ---> c022428e0aeb
Step 12/16 : RUN wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value
 ---> Running in ec4573cffcf1
No Instance(s) Available.



Removing intermediate container ec4573cffcf1
 ---> 6d21280107d8
Step 13/16 : RUN wmic datafile where name="C:\\chrome.exe" get Version /value
 ---> Running in 5d6634bfa50e
No Instance(s) Available.



Removing intermediate container 5d6634bfa50e
 ---> 0b587b578c84
Step 14/16 : RUN wmic datafile where name="C:\\chromeapp\\chrome.exe" get Version /value
 ---> Running in 3cdede74551c
No Instance(s) Available.



Removing intermediate container 3cdede74551c
 ---> 235d73eb5b86
Step 15/16 : EXPOSE 4444
 ---> Running in 251cb2576a80
Removing intermediate container 251cb2576a80
 ---> 1d33c5e397e4
Step 16/16 : CMD [ "java -jar ./selenium-server-standalone-3.141.59.jar"]
 ---> Running in 31ada643e847
Removing intermediate container 31ada643e847
 ---> 94dd3134e4ad
Successfully built 94dd3134e4ad
Successfully tagged local/selenium_server:latest

Output of docker run -d -p 4444:4444 local/selenium_server

c3049079e9115751d06eb8c1c3e37cf8133e5722cdd609a7bdfe5957b8189b08

Output of docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                    NAMES
c3049079e911        local/selenium_server   "java -jar ./seleniu…"   19 seconds ago      Up 14 seconds       0.0.0.0:4444->4444/tcp   upbeat_antonelli

Describe the results you expected:
I should be able to create a new session on selenium grid.

Additional information you deem important (e.g. issue happens only occasionally):
I’m using python/selenium for Regression tests via UI.
I have setup the binary_location as well but I still can’t make it to work.

Output of docker version :

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:31 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:28:48 2019
  OS/Arch:          windows/amd64
  Experimental:     false

Output of docker info :

Containers: 3
 Running: 0
 Paused: 0
 Stopped: 3
Images: 102
Server Version: 18.09.2
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: ics l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 18362 (18362.1.amd64fre.19h1_release.190318-1202)
Operating System: Windows 10 Enterprise Version 1903 (OS Build 18362.267)
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 15.93GiB
Name: NPHIL201607-03
ID: SGRR:CAUQ:5CU6:5RME:JCEA:OCPI:RIEN:XTWT:3IHO:3ZUH:IKUK:BZPM
Docker Root Dir: D:\Docker\Data
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: -1
 Goroutines: 48
 System Time: 2019-07-31T10:45:32.9509217+10:00
 EventsListeners: 1
HTTP Proxy: http://111.111.11.111:8080
HTTPS Proxy: http://111.111.11.111:8080
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

Additional environment details (AWS, VirtualBox, physical, etc.):
Sample DOCKERFILE:

FROM openjdk:windowsservercore-1803

WORKDIR /chromeapp

#download standalone file from seleniumhq https://www.seleniumhq.org/download/
COPY selenium-server-standalone-3.141.59.jar ./

#chromedriver environment path
ENV WEBDRIVERS="C:\webdrivers"

#download chromedriver
RUN iwr "https://chromedriver.storage.googleapis.com/75.0.3770.140/chromedriver_win32.zip" -Proxy "http://111.111.11.111:8080" -OutFile 'C:\chromedriver.zip' -UseBasicParsing; \
    Expand-Archive C:\chromedriver.zip -DestinationPath $env:WEBDRIVERS; \
    Remove-Item C:\chromedriver.zip;

#add to PATH
SHELL ["cmd", "/S", "/C"]
RUN setx /M PATH "%PATH%;%WEBDRIVERS%"

#go back to powershell commands after running command prompt commands
SHELL ["Powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
#download chrome
RUN iwr "https://dl.google.com/chrome/install/75/chrome_installer.exe" -Proxy "http://111.111.11.111:8080" -OutFile 'C:\chrome_installer.exe' -UseBasicParsing; 
#install chrome
RUN C:\chrome_installer.exe /silent /install

#run command prompt commands for checking google default installation
SHELL ["cmd", "/S", "/C"]
RUN wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value

RUN wmic datafile where name="C:\\chrome.exe" get Version /value

RUN wmic datafile where name="C:\\chromeapp\\chrome.exe" get Version /value

EXPOSE 4444

CMD [ "java -jar ./selenium-server-standalone-3.141.59.jar"]

Access Selenium Hub via Local exposed port
image

Create Session
choose chrome as browser:
image
hit “ok” button:
image

Got any solution for this issue ?

Facing the same issue, unable to launch the chrome head less browser through selenium java code. @aredz6 any solution for this issue?

Still searching solution for this issue, please let me know if any one created/used Docker windows containers for selenium headless/normal executions.

@akshayshar @seerapu

I’ve made this work by just replacing the dynamic download of standalone chrome to just a manual download + copy and install silently.

here’s the updated dockerfile

FROM openjdk:windowsservercore-1803

WORKDIR /chromeapp

#download standalone file from seleniumhq https://www.seleniumhq.org/download/
COPY selenium-server-standalone-3.141.59.jar ./

#chromedriver environment path
ENV WEBDRIVERS=“C:\webdrivers”

#download chromedriver
RUN iwr “https://chromedriver.storage.googleapis.com/75.0.3770.140/chromedriver_win32.zip” -Proxy “http://111.111.111.111:8080” -OutFile ‘C:\chromedriver.zip’ -UseBasicParsing;
Expand-Archive C:\chromedriver.zip -DestinationPath $env:WEBDRIVERS;
Remove-Item C:\chromedriver.zip;

#add to PATH
SHELL [“cmd”, “/S”, “/C”]
RUN setx /M PATH “%PATH%;%WEBDRIVERS%”

#go back to powershell commands after running command prompt commands
SHELL [“Powershell”, “-Command”, “$ErrorActionPreference = ‘Stop’;”]
#copy chrome
COPY ./ChromeStandaloneSetup64.exe ./
#install chrome
RUN .\ChromeStandaloneSetup64.exe /silent /install

#run command prompt commands for checking google default installation
SHELL [“cmd”, “/S”, “/C”]
RUN wmic datafile where name=“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” get Version /value

EXPOSE 4444

ENTRYPOINT [“java”]

then use docker command to instantiate hub
docker run -d -p 4444:4444 --name selenium-hub -jar selenium-server-standalone-3.141.59.jar

note: just make sure your standalone chrome is the same version as your chromedriver