RobCherry / docker-chromedriver

Docker container for creating ChromeDriver servers
99 stars 74 forks source link

"Chrome failed to start" #7

Open davidnortonjr opened 7 years ago

davidnortonjr commented 7 years ago

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
RobCherry commented 7 years ago

Can you also share logs from the /var/logs/supervisor folder?

davidnortonjr commented 7 years ago

Rob - attached. xvfb.log and tinywm.log were empty.

chromedriver.log.txt supervisord.log.txt

RobCherry commented 7 years ago

@davidnortonjr Sorry it has taken so long for me to respond. I have been unable to reproduce in my stack... Something you could try to help debug would be adding --verbose to the chromedriver command (you would need to modify /etc/supervisor/conf.d/chromedriver.conf) and see if you get any additional logging output to indicate what the failure may be.

Example Dockerfile:

FROM robcherry/docker-chromedriver:latest
ADD your-custom-chromedriver.conf /etc/supervisor/conf.d/chromedriver.conf

Then you can run it just like anything else...

docker build -t chromedriver:testing .
docker run --rm --name chromedriver -p 127.0.0.1:4444:4444 -e CHROMEDRIVER_WHITELISTED_IPS='' chromedriver:testing

Let me know if that helps.

RobCherry commented 7 years ago

Also, what version of WebDriver are you using?

davidnortonjr commented 7 years ago

Thanks for that. I got an updated chromedriver.log file which contains more detail.

chromedriver.log.txt

we're using Polymer Web Component Tester, which uses the Node wd library.

RobCherry commented 7 years ago

Hm, what OS and Kernel are you running? Based on your logs it looks like this is your problem:

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted

I am not experiencing any issues, but I am running Ubuntu Trusty (64-bit) w/ Kernel 3.13.0-71 in a VM. Also not experiencing issues running on CoreOS 1185.5.0 (Stable Channel).

There may be some useful info in this issue https://github.com/jessfraz/dockerfiles/issues/65, or you could attempt to run as a privileged container and see if that fixes the issue.

International commented 7 years ago

I also encountered this issue. Running with privileged fixed it. Thanks @RobCherry

RobCherry commented 7 years ago

@International Could you provide more information about what operating environment you were in when you experienced the issue? I would love to know what triggers it so I can reproduce and try to find a better work-around than running privileged.

International commented 7 years ago

Sure, I'm running OSX 10.11.6 El Capitan. The docker version I'm running is:

Version 1.12.5 (14777)
Channel: Stable
3e6f00c1dc

Do you need other program versions?

RobCherry commented 7 years ago

No, that is good information. I haven't tried with Docker for Mac, so I will have to give it a whirl and see how that impacts the container.

pschultz commented 7 years ago

We're running on a Linux host. For a second or so there's a Chrome log at /tmp/.org.chromium.Chromium.*/chrome_debug.log:

root@467d88022e0d:/tmp# tail -F .*/chrome_debug.log [10542:10542:0123/163945: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.

root@467d88022e0d:/tmp# google-chrome --version
Google Chrome 54.0.2840.59 

$ docker inspect -f '{{.Id}}' robcherry/docker-chromedriver
sha256:f7a799398d7e3b545a4ec37d0460d44121626484b209504b3f2bc0fccb7fc82c

Maybe 84d8a7e50c369a5a5a52f6d834bc701b5b03f964 broke it?

RobCherry commented 7 years ago

What linux host (distro, kernel version, etc)? At the very lease please provide the output of uname -a.

pschultz commented 7 years ago
$ uname -a
Linux runner-f775b9ab-1485857266-60965ead 4.7.3-coreos-r2 #1 SMP Sun Jan 8 00:32:25 UTC 2017 x86_64 Intel(R) Xeon(R) CPU @ 2.50GHz GenuineIntel GNU/Linux

$ cat /etc/os-release
NAME="Container Linux by CoreOS"
ID=coreos
VERSION=1235.6.0
VERSION_ID=1235.6.0
BUILD_ID=2017-01-10-0545
PRETTY_NAME="Container Linux by CoreOS 1235.6.0 (Ladybug)"
ANSI_COLOR="38;5;75"
HOME_URL="https://coreos.com/"
BUG_REPORT_URL="https://github.com/coreos/bugs/issues"

That's the current coreos-stable image on GCE.

mattiamoretta commented 7 years ago

Hi all,

having the same issue that Chrome is crashing:

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.9.27-14.33.amzn1.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.12 seconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: '4d71782b5c7a', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.27-14.33.amzn1.x86_64', java.version: '1.8.0_121'

I was trying to access to the chromedriver.conf file but I didn't properly understand how to do it :(

FROM robcherry/docker-chromedriver:latest ADD your-custom-chromedriver.conf /etc/supervisor/conf.d/chromedriver.conf

What should I do with this docker file?

Thanks a lot,

Mattia

pschultz commented 7 years ago

You can either create a new image with your own config file, or supply it at runtime. To build the image, using the Dockerfile you pasted:

docker build -t my-docker-chromedriver .

To supply it runtime use the -v flag:

docker run \
    -v /path/to/your-custom-chromedriver.conf:/etc/supervisor/conf.d/chromedriver.conf:ro \ 
    robcherry/docker-chromedriver:latest

See docker run and docker build for details.

mattiamoretta commented 7 years ago

Same cause:

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted

Adding --privileged solved the issue.

Was executing containers without privileges until now, don't understand why I have to consider them now.

Thanks again,

Mattia

dbpolito commented 7 years ago

OMG... this took a really long time for me to figure out... adding privileged fixed for me too... Which makes me think what's here that makes this necessary...

RobCherry commented 7 years ago

If someone wants to test with https://github.com/RobCherry/docker-chromedriver/commit/84d8a7e50c369a5a5a52f6d834bc701b5b03f964 reverted and let me know if it works please let me know and I can revert that change.

marinator86 commented 7 years ago

@RobCherry I tried and it didn't work for me. Output:

chromedriver.log.txt

Hope that helps a bit.

RobCherry commented 7 years ago

Yeah, IIRC the FATAL in that log was why it originally had the --disable-setuid-sandbox wrapper (the code removed in https://github.com/RobCherry/docker-chromedriver/commit/84d8a7e50c369a5a5a52f6d834bc701b5b03f964).

[964:964:0803/150525.178831: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.

If anyone is interested in some light reading:

https://bugs.chromium.org/p/chromium/issues/detail?id=598454

https://chromium.googlesource.com/chromium/src/+/lkcr/docs/linux_suid_sandbox_development.md

https://bugs.chromium.org/p/chromium/issues/detail?id=312380

Feel free to figure out what works and submit a pull request.

SophisticaSean commented 6 years ago

I found this was only an issue on Mac OS. I tested this on a server running ubuntu 16.04 with the exact same docker files and it worked just fine. I'm guessing its a very weird problem in OSX docker.

Fohlen commented 6 years ago

I tested this container and it works fine on OSX. Please note that #13 is required.

dimasusername commented 5 years ago

Those having issues on MacOS may want to edit /etc/docker/daemon.json

or using the Docker app and going into Settings > Daemon

and set

"default-shm-size":"2g"

http://fuzzyblog.io/blog/docker/2017/09/30/using-chrome-driver-with-docker-rails-and-selenium-on-aws.html

zloirog commented 5 years ago

Is there a way to run it without --privileged?

I am using bitbucket pipelines and there this flag is restricted.

https://confluence.atlassian.com/bitbucket/run-docker-commands-in-bitbucket-pipelines-879254331.html

https://bitbucket.org/site/master/issues/13420/allow-docker-image-privileged-flag