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
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
Selective Core Dump in Linux - How to Select the Dumped Sections
How to Add Date String to Each Line of a Continuously Written Log File
Perf_Event_Open Overflow Signal
Why Is There No Directx API for Linux
Cannot Install Docker in a Rhel Server
How to Sleep for 1 Second Between Each Xargs Command
Search for a Cronjob with Crontab -L
Installing Jenkins Plugins to Docker Jenkins
Why Can't Files Be Manipulated by Inode
How to Extract Numbers from a String
Saving Gmon.Out Before Killing a Process
Munmap() Failure with Enomem with Private Anonymous Mapping
Are Unix Reads and Writes to a Single File Atomically Serialized
Application 'Appname' Failed to Start (Port 8080 Not Available) on Open Shift Node App
How to Install Anaconda/Miniconda on Linux Silently
Embedding an Icon in a Linux Executable
Centos Error - Sudo: Effective Uid Is Not 0, Is Sudo Installed Setuid Root