docker official dind build (docker:latest) with chromiuim - google-chrome

I've been trying for the last two days to get chromuim installed and running on docker:latest docker image. (docker in docker).
I have tried multiple docker files:
from docker:latest
RUN apk add --no-cache python py2-pip curl bash chromuim ttf-freefont xvfb nodejs nodejs-npm udev
RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:~/google-cloud-sdk/bin
RUN pip install docker-compose
RUN npm install -g #angular/cli swagger
ENV CHROME_BIN=/usr/bin/chromium-browser
This installed chrome 57, which doesn't support headless.
So I suspect I can run this with xvbf, but running this chrome fails with:
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
[8:8:1124/085514.600081:FATAL:zygote_host_impl_linux.cc(182)] Check failed: ReceiveFixedMessage(fds[0], kZygoteBootMessage, sizeof(kZygoteBootMessage), &boot_pid).
Aborted (core dumped)
So I tried to install chrome 61 (which supported headless).
But for that you need to update the Dockerfile to use edge.
I tried to upgrade / or install 61 right away. I always get fonts missing.
The closest I got was adjusting my dockerfile to use lighthose one
from docker:latest
RUN apk add --no-cache python py2-pip curl bash xvfb nodejs nodejs-npm udev
RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:~/google-cloud-sdk/bin
RUN pip install docker-compose
RUN npm install -g #angular/cli swagger
ENV CHROME_BIN=/usr/bin/chromium-browser
USER root
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN echo "http://dl-2.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
#-----------------
# Set ENV and change mode
#-----------------
ENV LIGHTHOUSE_CHROMIUM_PATH /usr/bin/chromium-browser
ENV TZ "Europe/Berlin"
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
ENV SCREEN_WIDTH 750
ENV SCREEN_HEIGHT 1334
ENV SCREEN_DEPTH 24
ENV DISPLAY :99.0
ENV PATH /lighthouse/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV GEOMETRY "$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
RUN echo $TZ > /etc/timezone
#-----------------
# Add packages
#-----------------
RUN apk -U --no-cache update
RUN apk -U --no-cache add \
zlib-dev \
chromium \
freetype \
ttf-opensans \
xvfb \
wait4ports \
xorg-server \
dbus \
ttf-freefont \
mesa-dri-swrast
# Minimize size
RUN apk del --purge --force curl make gcc g++ python linux-headers binutils-gold gnupg git zlib-dev apk-tools libc-utils
RUN rm -rf /var/lib/apt/lists/* \
/var/cache/apk/* \
/usr/share/man \
/tmp/* \
/usr/lib/node_modules/npm/man \
/usr/lib/node_modules/npm/doc \
/usr/lib/node_modules/npm/html \
/usr/lib/node_modules/npm/scripts
VOLUME /lighthouse/output
ADD xvfb-chromium.sh /chromium-xvfb.sh
RUN chmod +x /chromium-xvfb.sh
xvfb-chromium.sh (althought not need, as you can docker run /bin/bash into the container)
#!/bin/sh
_kill_procs() {
kill -TERM $chromium
wait $chromium
kill -TERM $xvfb
}
parameters=$#
# We need to test if /var/run/dbus exists, since script will fail if it does not
[ ! -e /var/run/dbus ] && mkdir /var/run/dbus
/usr/bin/dbus-daemon --system
# Setup a trap to catch SIGTERM and relay it to child processes
trap _kill_procs SIGTERM
TMP_PROFILE_DIR=`mktemp -d -t chromium.XXXXXX`
export CHROME_DEBUGGING_PORT=9222
# Start Xvfb
Xvfb ${DISPLAY} -ac +iglx -screen 0 ${GEOMETRY} -nolisten tcp & xvfb=$!
printf "Starting xvfb window server..."
while [ 1 -gt $xvfb ]; do printf "..."; sleep 1; done
printf "xvfb started\n\n"
#printf "Starting chromium, with debugger on port $CHROME_DEBUGGING_POST...\n\n"
# --disable-webgl \
$CHROME_BIN \
--no-sandbox \
--user-data-dir=${TMP_PROFILE_DIR} \
--start-maximized \
--remote-debugging-port=${CHROME_DEBUGGING_PORT} \
--no-first-run "about:blank" &
#chromium=$!
#wait4ports tcp://127.0.0.1:$CHROME_DEBUGGING_PORT
printf "\n\n==============================\nlaunching lighthouse run\n==============================\n\n"
#wait $chromium
wait $xvfb
Then I got another error:
Error relocating /usr/lib/chromium/chrome: FT_Set_Default_Properties: symbol not found
Not sure how to solve this, any help would be appreciated.

you could try this link https://github.com/c0b/chrome-in-docker
It downloads a google-chrome Linux version from chrome channels, either stable, or beta, or developer version;It turns google-chrome into a headless browser,

Related

Unable to run chromedp in docker

I had installed chromedp locally using this usual way:-
$ go get -u github.com/chromedp/chromedp. I am able to run it locally but when I deployed it to my stage environment, I got below error:-
exec: \"google-chrome\": executable file not found in $PATH
What changes do I need to make in my dockerfile?
Note: I have already tried adding below code in my Dockerfile as suggested in this answer, still doesn't work
RUN apk update && apk upgrade && apk add --no-cache bash git && apk add --no-cache chromium
# Installs latest Chromium package.
RUN echo #edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
&& echo #edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
&& apk add --no-cache \
harfbuzz#edge \
nss#edge \
freetype#edge \
ttf-freefont#edge \
&& rm -rf /var/cache/* \
&& mkdir /var/cache/apk
RUN go get github.com/mafredri/cdp
CMD chromium-browser --headless --disable-gpu --remote-debugging-port=9222 --disable-web-security --safebrowsing-disable-auto-update --disable-sync --disable-default-apps --hide-scrollbars --metrics-recording-only --mute-audio --no-first-run --no-sandbox```
It took me a while to figure out this problem originally, it's not just you.
When your installing chromedp on your local machine it's grabbing the package and building for that specific distro. When you run it inside docker you need to download a specific chromium build for the distro you are running inside docker. This is because deb is different than rpm is different than alpine and you need to have the right chromium.
Here is a copy of my docker file using a basic linux distro
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub |
apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >>
/etc/apt/sources.list.d/google.list
RUN apt-get update && apt-get -y install google-chrome-stable
RUN chrome &
WORKDIR /app/svc/worker
RUN go build -o main .
EXPOSE 6061
CMD ["./main"]
This version for Alpine might work https://pkgs.alpinelinux.org/packages?name=chromium&branch=v3.10. However, in my experience it is best not to go with a minimal distro because chrome might depend on features not included in alpine.

centos7: Operation not permitted - mysql

I have installed mysql in centOS and now, want to start the mysql-server. However, I get that error:
# systemctl start mysqld
Failed to get D-Bus connection: Operation not permitted
To fix it, I created a Dockerfile as shown
FROM centos:7
MAINTAINER theodosiostziomakas <mymail#gmail.com>
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i
== systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
And then run it to create an image.
$ docker build --rm -t local/c7-systemd .
But I am still getting the same error.
I also looked at this proposed solution
Any ideas?
Thanks,
Theo.
I believe the issue with the Dockerfile or with the run command
It seems the issue in you Dockerfile is in this line
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
Here is MySQL centos Dockerfile
# Starting from base CentOS image
FROM centos:7
# Enabling SystemD
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
# Enabling EPEL & Remi repo
#RUN yum install -y epel-release && \
#yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# Mysql repo & installion
RUN yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm && \
yum install -y mysql mysql-server
RUN chkconfig --level 345 mysqld on
RUN systemctl enable mysqld
VOLUME [ "/var/lib/mysql" ]
# Port Expose
EXPOSE 3306
CMD ["/usr/sbin/init"]
Now, Next step is to run
--privileged is not enough, you also need to mount cgroup
Here is the command
docker run --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro -it adilm7177/centos-mysql
You can build your own or you can pull the above image from docker registry that i build and push during testing.
docker push adilm7177/centos-mysql:latest
Update:
RUN systemctl enable mysqld
After adding this I am able to start-stop using systemctl
I am able to run mysql just fine with the docker-systemctl-replacement script which emulates "systemctl" commands without an active systemd daemon. You can look at that at the docker-systemctl-images examples.

Robot Framework - Docker - Chromedriver

I'm trying to setup a container to test with RobotFramework on chrome.
But when I run my container I keep getting a WebDriverException.
I've searched but couldn't find any fix that actually works for me.
This is my Dockerfile
FROM python:3
RUN apt-get update -y
# Dependencies
RUN apt-get install -y \
apt-utils \
build-essential \
fonts-liberation \
gconf-service \
libappindicator1 \
libasound2 \
libcurl3 \
libffi-dev \
libgconf-2-4 \
libindicator7 \
libnspr4 \
libnss3 \
libpango1.0-0 \
libssl-dev \
libxss1 \
python-dev \
python-pip \
python-pyasn1 \
python-pyasn1-modules \
unzip \
wget \
xdg-utils \
xvfb \
libappindicator3-1 \
libatk-bridge2.0-0 \
libgtk-3-0 \
lsb-release
# Install Chrome for Selenium
RUN curl https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /chrome.deb
RUN dpkg -i /chrome.deb || apt-get install -yf
RUN rm /chrome.deb
# Install chromedriver for Selenium
RUN curl https://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip -o /usr/local/bin/chromedriver
RUN unzip -o /usr/local/bin/chromedriver -d /usr/local/bin
RUN chmod +x /usr/local/bin/chromedriver
WORKDIR /home
COPY . .
RUN pip install -e .
CMD [ "pybot","./tests/test.robot" ]
This is the error I keep getting
WebDriverException: Message: unknown error: Chrome failed to start:
exited abnormally (unknown error: DevToolsActivePort file doesn't
exist) (The process started from chrome location
/usr/bin/google-chrome is no longer running, so ChromeDriver is
assuming that Chrome has crashed.) (Driver info:
chromedriver=2.42.591071
(0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux
4.15.0-34-generic x86_64)
My test.robot:
*** Settings ***
Library Selenium2Library
*** Variables ***
*** Test Cases ***
Connect
Open Browser https://google.es Chrome
I think I am missing something but, I just dont know what to do.
On my setup.py:
install_requires=[
'robotframework',
'robotframework-selenium2library',
'selenium'
]
I ran into this issue recently using a docker container and Amazon Linux running robot tests. I found that even though I added the required arguments within the robot framework test as in the example below chrome was crashing without even starting with the same message you received. I resolved the issue by updating the python settings in the options.py within the container.
I updated my docker container with the command below to set the options in the python selenium chrome WebDriver options.py file. In my case I'm using python version 3.7 - so you want to make sure that the path you use is correct.
RUN sed -i "s/self._arguments\ =\ \[\]/self._arguments\ =\ \['--no-sandbox',\ '--disable-dev-shm-usage'\]/" /usr/local/lib/python3.7/site-packages/selenium/webdriver/chrome/options.py
Example Robot - this is what I tried within robot framework that didn't fix the problem.
${chrome_options} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${chrome_options} add_argument headless
Call Method ${chrome_options} add_argument disable-gpu
Call Method ${chrome_options} add_argument no-sandbox
Call Method ${chrome_options} add_argument disable-dev-sim-usage ${options}= Call Method ${chrome_options} to_capabilities
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
open browser about:blank ${BROWSER} desired_capabilities=${options}
I'm not sure if this will address your issue. You could try updating your file manually before updating your container to see if it helps. I spent a lot of time troubleshooting this. It would be great if the error was a bit more descriptive.
Good luck.
Please change modify permission , it's will work
from
RUN chmod +x /usr/local/bin/chromedriver
to
RUN chmod 777 /usr/local/bin/chromedriver
I had the same issue and the below code fixed it
*** Settings ***
Library Selenium2Library
*** Variables ***
${URL} https://www.google.com
${CHROMEDRIVER_PATH} /usr/local/bin/chromedriver
*** Keywords ***
Open Website
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${chrome_options} add_argument --no-sandbox
Call Method ${chrome_options} add_argument --headless
Open Browser ${URl} chrome options=${chrome_options} executable_path=${CHROMEDRIVER_PATH}
*** Settings ***
Suite Setup Open Website
This is my Dockerfile have test with gitlab CI:
FROM python:3.9.6-buster
ADD ./requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN apt-get update && apt-get install -y xvfb wget unzip libnss3-tools
RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN apt-get update && apt-get install -y google-chrome-stable
RUN wget -q https://chromedriver.storage.googleapis.com/91.0.4472.101/chromedriver_linux64.zip -O /tmp/chromedriver_linux64.zip \
&& unzip -qq /tmp/chromedriver_linux64.zip -d /usr/local/bin \
&& rm /tmp/chromedriver_linux64.zip \
&& chmod +x /usr/local/bin/chromedriver
You can get more information to run Robot Framework with docker:
https://github.com/dylanops/docker-robot-framework

run puppeteer without desktop environment

Is possible to run puppeteer on my Debian environment ? I don't have the desktop environment installed on it.
When I run my example.js script I have a Error: Failed to launch chrome! libX11-xcb.so.1: cannot open shared object file: No such file or directory
Thx
Ok I found the solution:
Install the Debian required dependencies to use chromium:
apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
And launch the browser without the sandbox:
example.js:
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({args: ['--no-sandbox']});
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'example.png'});
browser.close();
})();
Maybe some useful documentation here:
https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker
The use of --no-sandbox is described as "strongly discouraged", but there are hints about running Puppeteer in a Docker container which should solve the missing shared libraries issues.
The Dockerfile suggested in the above mentioned link is:
FROM node:12-slim
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# If running Docker >= 1.13.0 use docker run's --init arg to reap zombie processes, otherwise
# uncomment the following lines to have `dumb-init` as PID 1
# ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_x86_64 /usr/local/bin/dumb-init
# RUN chmod +x /usr/local/bin/dumb-init
# ENTRYPOINT ["dumb-init", "--"]
# Uncomment to skip the chromium download when installing puppeteer. If you do,
# you'll need to launch puppeteer with:
# browser.launch({executablePath: 'google-chrome-stable'})
# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# Install puppeteer so it's available in the container.
RUN npm i puppeteer \
# Add user so we don't need --no-sandbox.
# same layer as npm install to keep re-chowned files from using up several hundred MBs more space
&& groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /node_modules
# Run everything after as non-privileged user.
USER pptruser
CMD ["google-chrome-stable"]
Then the suggested Docker build and run commands are:
docker build -t puppeteer-chrome-linux .
docker run -i --init --rm --cap-add=SYS_ADMIN \
--name puppeteer-chrome puppeteer-chrome-linux \
node -e "`cat yourscript.js`"
I tested the process described here above myself , and after that received a no usable sandbox error (therefore the missing shared object error appeared to be solved by it).
Concerning the sandbox related error, suggested resolution from the same source than mentioned here above, is enabling user namespace cloning.
sudo sysctl -w kernel.unprivileged_userns_clone=1

How do I resolve WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally in Docker?

I am trying to run tests in a Docker, which currently run on a Jenkins slave, so bare metal. To make it more portable I try to get the Robot Framework running inside it, but so far with no luck.
This is my Dockerfile to create the robot image:
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
dbus \
libgtk2.0-0 \
libgconf-2-4 \
libnss3 \
nginx \
python3 \
python3-pip \
xvfb
# google chrome requirements
RUN apt-get install -y --no-install-recommends \
fonts-liberation \
gconf-service \
libappindicator1 \
lsb-release \
wget \
libasound2 \
ibatk-bridge2.0-0 \
libgtk-3-0 \
libxss1 \
libxtst6 \
xdg-utils
COPY google-chrome-stable_current_amd64.deb /tmp
RUN dpkg --install /tmp/google-chrome-stable_current_amd64.deb && \
apt-get install -f -y && \
rm /tmp/google-chrome-stable_current_amd64.deb
# update pip & install robot framework
RUN pip3 install --upgrade pip \
setuptools && \
pip3 install robotframework \
robotframework-selenium2library \
robotframework-xvfb
COPY chromedriver /usr/local/bin
RUN chmod +x /usr/local/bin/chromedriver
WORKDIR /usr/src/robot
CMD /etc/init.d/nginx start && python3 -m robot --include ready BasicTest.robot
Then I run the test image by calling:
$ docker run -ti --rm -v "$PWD/src/test/robot-framework":/usr/src/robot -v "$PWD/dist":/var/www/html:ro --add-host databasehost:10.10.10.10 robot
src/test/robot-framework contains the BasicTest.robot file and the dist folder is the created dist folder for an Angular-based project I want to test.
The messages I get, after waiting a longer time, look like this:
Correct Login :: *Description:* | FAIL |
Setup failed:
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.9.60-linuxkit-aufs x86_64)
I start the virtual display in the BasicTest.robot by:
Start Virtual Display 1024 768
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${chrome_options} add_argument headless
Call Method ${chrome_options} add_argument disable-gpu
Call Method ${chrome_options} add_argument no-sandbox
Open Browser #{url} #{browser} --auto-ssl-client-auth
I am not sure what is the purpose of your project, but here is my Dockerfile that uses puppeteer that is a Google Lib that wraps chrome_headless and allow you to use it more easily.
Here you can find an official example and here is the official documentation of puppeteer with great community suppport.
This is my Docker file that runs a npm script after building a container with puppeteer, node and chromium dependencies.
# Most part taken from https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
FROM node:8-slim
# # Manually install missing shared libs for Chromium.
RUN apt-get update && \
apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6
libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0
libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1
libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2
libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release
xdg-utils wget
COPY . /app/
WORKDIR app
# Install deps for server.
RUN npm install -g
# Install puppeteer so it can be required by user code that gets run in
# server.js. Cache bust so we always get the latest version of puppeteer when
# building the image.
ARG CACHEBUST=1
RUN npm install puppeteer#0.13.0
# Add pptr user.
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /app
# Run user as non privileged.
USER pptruser
EXPOSE 9222
CMD ["npm", "start"]
Inside that npm start script you can run your tests I guess.
The trick about using puppeteer inside a Docker container is that Docker does not install chromium dependencies automatically and then it fails when you try to use it.
Despite the fact of using puppeteer or not, that container will allow you to use chrome_headless inside and in my opinion is less heavy than the other examples that I found inside the documentation.
For running just type
docker run -d -i --rm --cap-add=SYS_ADMIN --network=${yourNetwork} --name ${image_name} ${container_name}
Hope that helps