GithubHelp home page GithubHelp logo

docker-chromedriver's Introduction

Docker container for creating a ChromeDriver server

Includes

  • ChromeDriver (Latest)
  • Google Chrome (Latest Stable)

Building the Docker Image

You can build the image by either building from GitHub or cloning the repository.

To build from GitHub:

docker build -t "robcherry/docker-chromedriver:latest" github.com/robcherry/docker-chromedriver

If you choose to clone the repository locally, cd in to the repository's root directory and run:

docker build -t "robcherry/docker-chromedriver:local" .

You can also pull the final built image from docker:

docker pull robcherry/docker-chromedriver:latest

Usage

The most basic usage is to run the container and expose the ChromeDriver port on all interfaces.

docker run --name chromedriver -P -d robcherry/docker-chromedriver:latest

If you want to restrict the ports to your local environment, you can do so using -p.

docker run --name chromedriver -p 127.0.0.1::4444 robcherry/docker-chromedriver:latest

Note: ChromeDriver restricts access to local connections by default. To allow external connections, you can pass in a custom CHROMEDRIVER_WHITELISTED_IPS environment variable. By default, this is set to 127.0.0.1, but this can by any comma separated list of IP addresses. Setting the value as empty will allow all remote connections.

docker run --name chromedriver -p 127.0.0.1::4444 -e CHROMEDRIVER_WHITELISTED_IPS='' robcherry/docker-chromedriver:latest

docker-chromedriver's People

Contributors

robcherry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

docker-chromedriver's Issues

Session deleted because of page crash

Getting the following stacktrace when I try to execute nightwatch tests

INFO Got sessionId from selenium 60486302460536b6afcc4bd6f0d6074b
LOG     → Completed command pause (1004 ms)
INFO Request: POST http://chromedriver:4444/session/60486302460536b6afcc4bd6f0d6074b/url
 - data:  {"url":"http://frontend:80"}
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":28}
INFO Response 200 POST http://chromedriver:4444/session/60486302460536b6afcc4bd6f0d6074b/url (214ms) { sessionId: '60486302460536b6afcc4bd6f0d6074b',
  status: 13,
  value: { message: 'unknown error: session deleted because of page crash\nfrom tab crashed\n  (Session info: chrome=63.0.3239.84)\n  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.9.60-linuxkit-aufs x86_64)' } }
LOG     → Completed command url (217 ms)
INFO Request: GET http://chromedriver:4444/session/60486302460536b6afcc4bd6f0d6074b/screenshot
 - data:
 - headers:  {"Accept":"application/json"}
INFO Response 200 GET http://chromedriver:4444/session/60486302460536b6afcc4bd6f0d6074b/screenshot (3ms) { sessionId: '60486302460536b6afcc4bd6f0d6074b',
  status: 6,
  value: { message: 'no such session\n  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.9.60-linuxkit-aufs x86_64)' } }
LOG     → Completed command screenshot (5 ms)
INFO Request: POST http://chromedriver:4444/session/60486302460536b6afcc4bd6f0d6074b/elements
 - data:  {"using":"css selector","value":"body"}
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":39}
INFO Response 200 POST http://chromedriver:4444/session/60486302460536b6afcc4bd6f0d6074b/elements (5ms) { sessionId: '60486302460536b6afcc4bd6f0d6074b',
  status: 6,
  value: { message: 'no such session\n  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.9.60-linuxkit-aufs x86_64)' } }

I already increased the shm_size of docker to 2gb but the error still persists.

URL base and port

Just a remark because it confused me:

The combinations of port and URL base that I have seen so far are:

URL base Port Used by
/wd/hub 4444 Selenium
<empty> 9515 Chromedriver default
<empty> 4444 This Dockerfile

In your Dockerfile you have decided to go with port 4444 and URL base <empty>, is there a particular reason for that?

chrome start failing

unable to start the chrome:

Logs are as follows:
M-C02W329QHV2R:dashfrontendtest spatchava$ docker run --name chromedriver -p 127.0.0.1::4444 -e CHROMEDRIVER_WHITELISTED_IPS='' robcherry/docker-chromedriver:latest
2018-06-18 22:26:32,512 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2018-06-18 22:26:32,512 INFO Included extra file "/etc/supervisor/conf.d/chromedriver.conf" during parsing
2018-06-18 22:26:32,512 INFO Included extra file "/etc/supervisor/conf.d/tinywm.conf" during parsing
2018-06-18 22:26:32,512 INFO Included extra file "/etc/supervisor/conf.d/xvfb.conf" during parsing
2018-06-18 22:26:32,522 INFO RPC interface 'supervisor' initialized
2018-06-18 22:26:32,523 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2018-06-18 22:26:32,523 INFO supervisord started with pid 1
2018-06-18 22:26:33,531 INFO spawned: 'xvfb' with pid 8
2018-06-18 22:26:33,536 INFO spawned: 'tinywm' with pid 9
2018-06-18 22:26:33,539 INFO spawned: 'chromedriver' with pid 10
2018-06-18 22:26:33,553 INFO exited: tinywm (exit status 1; not expected)
2018-06-18 22:26:33,560 INFO exited: chromedriver (exit status 1; not expected)
2018-06-18 22:26:34,563 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-06-18 22:26:34,567 INFO spawned: 'tinywm' with pid 19
2018-06-18 22:26:34,570 INFO spawned: 'chromedriver' with pid 20
2018-06-18 22:26:34,578 INFO exited: chromedriver (exit status 1; not expected)
2018-06-18 22:26:35,583 INFO success: tinywm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-06-18 22:26:36,590 INFO spawned: 'chromedriver' with pid 25
2018-06-18 22:26:36,600 INFO exited: chromedriver (exit status 1; not expected)
2018-06-18 22:26:39,610 INFO spawned: 'chromedriver' with pid 30
2018-06-18 22:26:39,620 INFO exited: chromedriver (exit status 1; not expected)
2018-06-18 22:26:40,623 INFO gave up: chromedriver entered FATAL state, too many start retries too quickly

Version tags

Hi, thanks for a great container. Would you consider tagging the Docker image with a version so we can pick specific versions of Chrome, if necessary?

arm support welcome

Hey there @RobCherry
I was thinking about offering cross-platform builds for arm.
Since I am on OSX the toolchain is quite easy to set up (no QUEMU required).
Would you like this to be supported? Would you mind pushing the images to the repository?

The aim here is to build a small aggregation tool that can work on my Raspberry Pi. That surely takes away a lot of hassle if it runs in a Docker container!

Docker hub update dependencies

Is it possible to update "latest" dockerhub release? Because "robcherry/docker-chromedriver:latest" tag contains Chrome 66 and ChromeDriver 2.38.552522

--disable-setuid-sandbox still required for running chrome mobile

I am using PHP testing framework, Codeception, to run tests on chromedriver, which is in the container made from this image.

After updating to latest image version 04d52f73c6a0, my tests that running on chrome mobile are unable to run. Test just hang.

The image 118dc5673220 works, and I pulled this image about 2 months ago.

I guess the reason is this commit 84d8a7e and removing the command that disables the SUID sandbox.

I don't see anything in the log

root@99835ae32d28:/# cat /var/log/supervisor/supervisord.log 
2018-01-15 12:03:40,960 CRIT Supervisor running as root (no user in config file)
2018-01-15 12:03:40,960 INFO Included extra file "/etc/supervisor/conf.d/chromedriver.conf" during parsing
2018-01-15 12:03:40,960 INFO Included extra file "/etc/supervisor/conf.d/tinywm.conf" during parsing
2018-01-15 12:03:40,960 INFO Included extra file "/etc/supervisor/conf.d/xvfb.conf" during parsing
2018-01-15 12:03:40,971 INFO RPC interface 'supervisor' initialized
2018-01-15 12:03:40,971 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2018-01-15 12:03:40,972 INFO supervisord started with pid 1
2018-01-15 12:03:41,975 INFO spawned: 'xvfb' with pid 9
2018-01-15 12:03:41,979 INFO spawned: 'tinywm' with pid 10
2018-01-15 12:03:41,982 INFO spawned: 'chromedriver' with pid 11
2018-01-15 12:03:41,992 INFO exited: tinywm (exit status 1; not expected)
2018-01-15 12:03:43,000 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-01-15 12:03:43,001 INFO spawned: 'tinywm' with pid 28
2018-01-15 12:03:43,001 INFO success: chromedriver entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-01-15 12:03:44,002 INFO success: tinywm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-01-15 12:05:36,988 INFO reaped unknown pid 37
2018-01-15 12:05:36,988 INFO reaped unknown pid 38
2018-01-15 12:05:36,990 INFO reaped unknown pid 41
2018-01-15 12:06:34,771 INFO reaped unknown pid 115
2018-01-15 12:06:34,771 INFO reaped unknown pid 116
2018-01-15 12:06:34,773 INFO reaped unknown pid 119
2018-01-15 12:07:14,616 INFO reaped unknown pid 194
2018-01-15 12:07:14,616 INFO reaped unknown pid 195
2018-01-15 12:07:14,618 INFO reaped unknown pid 198
2018-01-15 12:08:21,458 INFO reaped unknown pid 272
2018-01-15 12:08:21,458 INFO reaped unknown pid 273
2018-01-15 12:08:21,459 INFO reaped unknown pid 276
2018-01-15 12:10:32,203 WARN received SIGTERM indicating exit request
2018-01-15 12:10:32,204 INFO waiting for tinywm, chromedriver, xvfb to die
2018-01-15 12:10:32,206 INFO stopped: chromedriver (terminated by SIGTERM)
2018-01-15 12:10:32,207 INFO stopped: tinywm (terminated by SIGTERM)
2018-01-15 12:10:32,220 INFO stopped: xvfb (exit status 0)
2018-01-15 12:10:34,530 CRIT Supervisor running as root (no user in config file)
2018-01-15 12:10:34,530 INFO Included extra file "/etc/supervisor/conf.d/chromedriver.conf" during parsing
2018-01-15 12:10:34,531 INFO Included extra file "/etc/supervisor/conf.d/tinywm.conf" during parsing
2018-01-15 12:10:34,531 INFO Included extra file "/etc/supervisor/conf.d/xvfb.conf" during parsing
2018-01-15 12:10:34,537 INFO RPC interface 'supervisor' initialized
2018-01-15 12:10:34,537 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2018-01-15 12:10:34,538 INFO supervisord started with pid 1
2018-01-15 12:10:35,539 INFO spawned: 'xvfb' with pid 9
2018-01-15 12:10:35,540 INFO spawned: 'tinywm' with pid 10
2018-01-15 12:10:35,541 INFO spawned: 'chromedriver' with pid 11
2018-01-15 12:10:36,547 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-01-15 12:10:36,547 INFO success: tinywm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-01-15 12:10:36,547 INFO success: chromedriver entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
root@99835ae32d28:/# cat /var/log/supervisor/chromedriver.log 
Starting ChromeDriver 2.34.522913 (36222509aa6e819815938cbf2709b4849735537c) on port 4444
All remote connections are allowed. Use a whitelist instead!
Starting ChromeDriver 2.34.522913 (36222509aa6e819815938cbf2709b4849735537c) on port 4444
All remote connections are allowed. Use a whitelist instead!
[620.194][SEVERE]: Timed out receiving message from renderer: 600.000
[1220.259][SEVERE]: Timed out receiving message from renderer: 600.000
[1307.496][SEVERE]: Timed out receiving message from renderer: 600.000

This is my codeception config

actor: AcceptanceTester
modules:
    enabled:
          - \Helper\Acceptance
          - WebDriver:
              host: chromedriver
              port: 4444
              url: %ASSETS_BASE_URI%
              window_size: 360x640
              browser: chrome
              capabilities:
                  chromeOptions:
                      mobileEmulation:
                          deviceName: 'Nexus 5'
extensions:
    enabled:
        - Codeception\Extension\RunProcess:
            - chromedriver

Btw, can you please version the docker images. Only tag is latest and it does not work for me. https://hub.docker.com/r/robcherry/docker-chromedriver/tags/

Don't use CMD

You're using CMD to run your program, which means no one can extend (FROM) your program and execute our own code after it.

"Chrome failed to start"

With the most recent update to the latest tag, our tests started failing:

chrome                   Tests failed: {"sessionId":"5375d30bf345d4c1d7183028f15af95a","status":13,"value":{"message":"unknown error: Chrome failed to start: crashed\n  (Driver info: chromedriver=2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e),platform=Linux 4.4.27-moby x86_64)"}}

These are the logs on the Chromedriver:

$ docker run --name chromedriver -p 127.0.0.1:4444:4444 -e CHROMEDRIVER_WHITELISTED_IPS='' robcherry/docker-chromedriver:latest
2016-12-12 11:08:02,465 CRIT Supervisor running as root (no user in config file)
2016-12-12 11:08:02,466 INFO Included extra file "/etc/supervisor/conf.d/chromedriver.conf" during parsing
2016-12-12 11:08:02,466 INFO Included extra file "/etc/supervisor/conf.d/tinywm.conf" during parsing
2016-12-12 11:08:02,466 INFO Included extra file "/etc/supervisor/conf.d/xvfb.conf" during parsing
2016-12-12 11:08:02,476 INFO RPC interface 'supervisor' initialized
2016-12-12 11:08:02,476 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2016-12-12 11:08:02,476 INFO supervisord started with pid 1
2016-12-12 11:08:03,484 INFO spawned: 'xvfb' with pid 9
2016-12-12 11:08:03,486 INFO spawned: 'tinywm' with pid 10
2016-12-12 11:08:03,488 INFO spawned: 'chromedriver' with pid 11
2016-12-12 11:08:04,499 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2016-12-12 11:08:04,500 INFO success: tinywm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2016-12-12 11:08:04,500 INFO success: chromedriver entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)





2016-12-12 11:08:19,537 INFO reaped unknown pid 31
2016-12-12 11:08:19,540 INFO reaped unknown pid 28
2016-12-12 11:08:19,540 INFO reaped unknown pid 29

Not working without SYS_ADMIN capability

Testing out this image together with Codeception. Connections to /wd/hub seem to hang unless --cap-add SYS_ADMIN is added when container is started.

Might be worth noting in README and on Docker Hub.

Docker 18.03.1-ce on Debian

Chrome fails to start with latest versions Chrome 54/Chromedriver 2.24

Just rebuild our image => got these versions

container:/# google-chrome --version
Google Chrome 54.0.2840.59

container:/# chromedriver --version
ChromeDriver 2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3)

the chromedriver service cannot start google chrome with option '--disable-setuid-sandbox' anymore.

container:/# /opt/google/chrome/google-chrome.real --disable-setuid-sandbox
[335:335:1024/052420:FATAL:zygote_host_impl_linux.cc(107)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
Aborted

You can replace the option with '--no-sandbox', as it says and it works again.

[SEVERE]: Timed out receiving message from renderer

I am using Google chrome headless with Selenium in maven following are the details

  1. Google Chrome 75.0.3770.100
  2. ChromeDriver 75.0.3770.90
  3. Selenium 3.141.59

When I run ChromeDriver with following options

ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
driver = new ChromeDriver(options);	
driver.get(prop.getProperty("url"));
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

It successfully executes all the test but also throws following error so this is not my worry
[1562587666.889][SEVERE]: bind() failed: Cannot assign requested address (99)
Although I have tried different suggestions but nothing seems working.

The real issue is when I set chrome windows size greater than 800,600 it stops working

ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--window-size=1920,1080");

and start throwing the following error on each test
[SEVERE]: Timed out receiving message from renderer and tests are not executed at all, remove the screen option and its working again.

This is driving me insane, I tried different combination of Chrome, ChromeDriver but no success, Kindly suggest something to resolve this.

Following is my Docker file

FROM maven:3.6.1-jdk-8

# Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
	&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
	&& apt-get update -qqy \
	&& apt-get -qqy install google-chrome-stable \
	&& rm /etc/apt/sources.list.d/google-chrome.list \
	&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
	&& sed -i 's/"$HERE\/chrome"/"$HERE\/chrome" --no-sandbox/g' /opt/google/chrome/google-chrome

# ChromeDriver
RUN CHROME_VERSION=$(google-chrome --version | grep -Eo "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,4}") \
	&& CHROME_DRIVER_VERSION=$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION) \
	&& wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
	&& rm -rf /opt/chromedriver \
	&& unzip /tmp/chromedriver_linux64.zip -d /opt \
	&& rm /tmp/chromedriver_linux64.zip \
	&& mv /opt/chromedriver /opt/chromedriver-$CHROME_DRIVER_VERSION \
	&& chmod 755 /opt/chromedriver-$CHROME_DRIVER_VERSION \
	&& chmod +x /opt/chromedriver-$CHROME_DRIVER_VERSION \
	&& ln -fs /opt/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver	

Thanks

Using volume

You also added a volume and didn't inlcude the contents... We are unable to extend your solution

chromedriver cant bind adress "[SEVERE]: bind() returned an error, errno=99: Cannot assign requested address (99)"

OS: Ubuntu 16.04.5 LTS
Docker: 18.06.0-ce, build 0ffa825

Steps to reproduce:
git clone https://github.com/RobCherry/docker-chromedriver
docker build -t test.
docker run -d --name="test" test
docker exec -it testbash
chromedriver

Results ins Error: "bind() returned an error, errno=99: Cannot assign requested address (99)"
Its also the same result when run as privileged

If I pull the image directly from docker hub it works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.