Google-Chrome Failed to Move to New Namespace

google-chrome Failed to move to new namespace

After researching extensively internet I think I found the answer:

Sandboxing 
For security reasons, Google Chrome is unable to provide sandboxing when it is running in the container-based environment.
To use Chrome in the container-based environment, pass the --no-sandbox flag to the chrome executable

So it looks like there is no better solution than --no-sandbox for me, even though its not being very secure, there are people on the internet claiming that it is still safe to use "--no-sandbox" as its running within container which is extra protected any way.

How to run google chrome headless in docker?

Using this image alpeware/chrome-headless-trunk worked for me in ubuntu!
The command used in that container to launch headless chrome is this:

/usr/bin/google-chrome-unstable \
--disable-gpu --headless --no-sandbox \
--remote-debugging-address=0.0.0.0 \
--remote-debugging-port=9222 --user-data-dir=/data

here's a short video of the container in action
chrome headless in action

I launched the container in Ubuntu with this command:

 docker run -it --rm -p=0.0.0.0:9222:9222 \ 
--name=chrome-headless \
-v /tmp/chromedata/:/data alpeware/chrome-headless-trunk

then used Chrome to connect to the debug port at localhost:9222

With some modifications you could probably get this running in Jenkins!

Sources

  • https://hub.docker.com/r/alpeware/chrome-headless-trunk/
  • https://github.com/alpeware/chrome-headless-trunk

Running headless Chrome / Puppeteer with --no-sandbox

I was hitting a similar problem trying to run Chromium headless in an Alpine Docker container, and apparently so are many other (e.g., here, here). The --no-sandbox option is a straightforward workaround but obviously a poor security practice. What worked for me was setting a custom seccomp.

Download this file (if interested, see the author's notes here). Then pass the option --security-opt seccomp=path/to/chrome.json when starting Docker, or specify the same option in your docker-compose.yml if you're using one.

Running google-chrome on WSL Ubuntu as --headless --no sandbox gives multiple errors - how do I take screenshot using headless in WSL?

Try this (tested in wsl2)

In your wsl2 ubuntu console enter the following commands:

#install packages
sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4 fonts-liberation
#get latest chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

#install it
sudo apt install ./google-chrome-stable_current_amd64.deb

#test a screenshot
google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/


Related Topics



Leave a reply



Submit