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:
https://github.com/ripper2hl/jenkinswithchrome
Jenkins official image:
https://github.com/jenkinsci/docker
The repo a person runs google chrome with GUI from docker:
https://github.com/jessfraz/dockerfiles/blob/master/chrome/stable/Dockerfile
My first approach is to use xvbf, but the process is more simple when used --headless flag.
https://gist.github.com/addyosmani/5336747
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
Just launch chrome with --no-sandbox that s resolves the problem
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
This article is exactly what I needed to run Karma tests with Headless Chrome inside docker:
https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
Basically, the solution is to run Headless Chrome with the --no-sandbox flag.
We built a Docker image with Chrome and Chromedriver that runs Chrome in headless mode for automated tests. We're using this as a drop-in replacement for PhantomJS in our docker-compose.yml setups. The image is based on Alpine Linux and doesn't need or include Selenium so it's pretty small.
Source:
https://github.com/retreatguru/headless-chromedriver
Docker Hub:
https://hub.docker.com/r/retreatguru/headless-chromedriver
I don't have the answer but I know a container which successfully launch a headless Chrome in Docker. The selenium one:
Selenium Chrome Node
I use it for automated testing of my webapp in Chrome
Hope it helps
I extend default Dockerfile Selenium Chrome Node by following
FROM selenium/standalone-chrome-debug:latest
MAINTAINER Serge Arbuzov <Serge.Arbuzov#advantechwireless.com>
USER root
### jenkins set up ###
RUN apt-get update && apt-get install -y openssh-server sudo
RUN mkdir /var/run/sshd
RUN adduser jenkins
RUN echo jenkins:jenkins | chpasswd
RUN echo "jenkins ALL=(ALL) NOPASSWD:ALL">>/etc/sudoers
USER root
RUN echo export DISPLAY=":1.5" >> /etc/environment
ADD run.sh /run.sh
RUN chmod +x /run.sh
EXPOSE 22
CMD ["/run.sh"]
And my run.sh is
#!/bin/bash
Xvfb :1 -screen 5 1024x768x8 &
/usr/sbin/sshd -D
So i can use default image as Jenkins node
Related
Issue: When I go to share my screen/tab/window on google meet, it comes up very dark.
very dark screenshot of shared screen.
Any ideas how to fix this?
Actions taken: all of the following with multiple logins/out/restarts but to no avail
You might need to update GDM3 custom configuration file
/etc/gdm3/custom.conf
Uncommenting this will force the login screen to use Xorg. #WaylandEnable=false
$ echo $XDG_SESSION_TYPE x11
Install xcompmgr using your Linux distro's package manager. sudo apt install xcompmgr After installing, open the terminal and run this command: xcompmgr -c -l0 -t0 -r0 -o.00 Open compton.conf gedit ~/.config/compton.conf Edit the following line: shadow-exclude = [ "name = 'cpt_frame_window' " ];
added google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland & to ~/.local/share/applications/google-chrome.desktop
set chrome://flags/#enable-webrtc-pipewire-capturer
sudo mkdir -p /etc/pipewire/media-session.d/ sudo cp /usr/share/pipewire/media-session.d/media-session.conf /etc/pipewire/media-session.d/ sudo sed -i 's/#metadata/metadata/g' /etc/pipewire/media-session.d/media-session.conf
Yours at a complete loss after many hours of digging around :)
OS: Ubuntu: 22.04.1 - clean minimal install
Browsers used: latest Firefox and Chrome
It is possible to run Google-chrome not Chromium with puppeteer in AWS Lambda with container?
Script stuck when I create new page in browser:
const page = await browser.newPage();
Logs from AWS lambda:
mkdir: cannot create directory ‘/.local’: Read-only file system
touch: cannot touch ‘/.local/share/applications/mimeapps.list’: No such file or directory
/usr/bin/google-chrome-stable: line 45: /dev/fd/62: No such file or directory
/usr/bin/google-chrome-stable: line 46: /dev/fd/62: No such file or directory
[0213/000419.523205:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[0213/000419.528197:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[0213/000419.648505:WARNING:audio_manager_linux.cc(60)] Falling back to ALSA for audio output. PulseAudio is not available or could not be initialized.
DevTools listening on ws://127.0.0.1:46195/devtools/browser/1d348770-1c99-48a5-934c-fae5254fc766
[0213/000419.769218:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
prctl(PR_SET_NO_NEW_PRIVS) failed
prctl(PR_SET_NO_NEW_PRIVS) failed
I do not use puppeteer but that doesn't matter much.
FROM public.ecr.aws/lambda/provided:al2
RUN yum install unzip atk at-spi2-atk gtk3 cups-libs pango libdrm \
libXcomposite libXcursor libXdamage libXext libXtst libXt \
libXrandr libXScrnSaver alsa-lib \
xorg-x11-server-Xvfb wget shadow-utils -y
COPY install-chrome.sh /tmp/
RUN /usr/bin/bash /tmp/install-chrome.sh
ENV DBUS_SESSION_BUS_ADDRESS="/dev/null"
I am not 100% DBUS_SESSION_BUS_ADDRESS is necessary. I am also not 100% sure whether explicitly naming all these packages are necessary, I stole everything from a dozen different places, likely the chrome rpm will pull in what it needs, but I never used any RHEL based system so I am totally clueless. I know this works. Optimizations are welcome.
Here's the script:
#!/usr/bin/bash
# Download and install chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
# Without -y it doesn't run because it needs to add dependencies.
yum install -y google-chrome-stable_current_x86_64.rpm
rm google-chrome-stable_current_x86_64.rpm
CHROMEVERSION=`wget -qO- https://chromedriver.storage.googleapis.com/LATEST_RELEASE`
wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROMEVERSION/chromedriver_linux64.zip
unzip /tmp/chromedriver_linux64.zip -d /opt
rm /tmp/chromedriver_linux64.zip
mv /opt/chromedriver /opt/chromedriver-$CHROMEVERSION
chmod 755 /opt/chromedriver-$CHROMEVERSION
ln -fs /opt/chromedriver-$CHROMEVERSION /usr/local/bin/chromedriver
# Create a user. /usr/sbin is not on $PATH.
/usr/sbin/groupadd --system chrome
/usr/sbin/useradd --system --create-home --gid chrome --groups audio,video chrome
You can verify it is working by starting it locally with docker run --mount type=tmpfs,destination=/tmp --read-only this simulates well the environment of AWS Lambda. Then you need to run su chrome -c 'xvfb-run chromedriver --allowed-ips=127.0.0.1'. I am using https://github.com/instaclick/php-webdriver/ which is a very thin PHP client for W3C and Selenium 2 webdriver. I used this to test:
<?php
namespace WebDriver;
require 'vendor/autoload.php';
#mkdir('/tmp/chrome');
chmod('/tmp/chrome', 0777);
$wd_host = 'http://localhost:9515';
$web_driver = new WebDriver($wd_host);
$session = $web_driver->session('chrome', [['goog:chromeOptions' => ['args' => [
'--no-sandbox',
'--user-data-dir=/tmp/chrome'
]]]]);
$session->open('https://google.com');
I'm installing MySQL server on my MacBook (M1 Chip). I run the following command to download the MySQL server
sudo docker pull mcr.microsoft.com/mssql/server:2019-latest
Then I run the following command to launch an instance of the Docker I just downloaded:
docker run -d --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=mypassword' -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest
But it pull a warning
WARNING: The requested image's platform (linux/amd64) does not match
the detected host platform (linux/arm64/v8) and no specific platform
was requested
559ff6b849b6e62cbdbfa3d7cde403f314798bffb4c1622aab8e305d3b49df97
Any one know how to fix this?
Try downloading using mac with apple chip
https://hub.docker.com/editions/community/docker-ce-desktop-mac?tab=description
I managed to solve this by installing mariadb instead of mysql
I have a simple startup script which looks like so:
#!/usr/bin/env bash
sudo apt update
sudo apt install -y ruby-full ruby-bundler build-essential
And create VM instance on GCP like so:
$ gcloud compute instances create test-app --boot-disk-size=10GB --image-family ubuntu-1604-lts --image-project=ubuntu-os-cloud --machine-type=g1-small --zone europe-west1-b --tags test-server --restart-on-failure --metadata-from-file startup-script=startup.sh
My startup.sh is executable. I set its rights like so:
$ chmod +x startup.sh
When however I enter the shell of my newly created instance and check bundler:
test-app:~$ bundle -v
I get these messages:
The program 'bundle' is currently not installed...
So, what is wrong with that and how can I fix it? PS. If I run all my commands just from inside the instance shell, it's all ok, so there is some problem with using startup script on GCP.
I tested with your use case, But the bundle package was installed without making any changes.
Output:
bundle -v
Bundler version 1.11.2
You can check VM serial console log output to verify if start-up script ran. Check the VM instance to verify if the package is installed using the commands below:
sudo apt list --installed | grep -i bundle
sudo egrep bundle /var/log/dpkg.log
In addition, check the gem list bundle
How do I test an IronWorker task locally using the CLI?
iron_worker run worker_name -p '{"foo":"bar","baz":[1,2,3]}'
where optional "-p" flag - payload
Assuming you have Docker installed you can also run your worker locally using a Docker command:
$ docker run --rm -v "$(pwd)":/worker -w /worker iron/php sh -c 'php name_of_worker.php'
Just make sure your Docker Quickstart Terminal is up and running.
If it works on Docker then it will work on IronIO. As stated in the Iron docs here.