How to run google chrome headless in docker?

Israel Perales picture Israel Perales · Apr 27, 2017 · Viewed 46.9k times · Source

My problem is how to run google chrome in docker container for e2e testing. I create a Dockerfile from official Jenkins image, but when try to run google chrome, it crashes and show the error:

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Trace/breakpoint trap (core dumped)

The Jenkins docker image uses Debian jessie.

I can run google chrome with --headless flag and the X server is not needed.

This is my docker file:

Jenkins official image:

The repo a person runs google chrome with GUI from docker:

My first approach is to use xvbf, but the process is more simple when used --headless flag.

I can run chrome in Ubuntu server with the same commands for installation, but in docker it fails.

After other intents, I used --no-sandbox flag, but docker images shows the next error.

[0427/180929.595479:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
[0427/180929.595537:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted

Actually I ran this command:

google-chrome-stable --headless --disable-gpu --no-sandbox http://www.google.com

Answer

Boikot picture Boikot · Aug 23, 2017

Just launch chrome with --no-sandbox that s resolves the problem