Installing and using browser on alpine-based docker images

Has anyone had success using browser on alpine-based images? I’m using ppodgorsek/robot-framework as the base image and created a new image with browser and a couple other things in it. Building the image is successful but when running a simple example test using browser, it seems to be missing some libraries. Any ideas if this would be fixable or am I better off using debian-based images?


FROM ppodgorsek/robot-framework:latest

USER 0:0

RUN apk update && apk upgrade && \
    apk add bash curl sudo build-base unixodbc-dev unixodbc freetds-dev gcc g++ curl gnupg iputils nodejs libressl-dev alsa-lib libbz2 && \
    apk add --no-cache tzdata && \
COPY ./requirements.txt /tmp/requirements.txt
RUN pip install -U pip
RUN pip3 install -r /tmp/requirements.txt

RUN rfbrowser init

RUN rm -rf /tmp/*

ENV PYTHONPATH=$PYTHONPATH:/opt/robotframework/tests





*** Settings ***
Library   Browser

*** Test Cases ***
Example Test
    New Page
    Get Text    h1    ==    🎭 Playwright

Then building and running it:

$ docker build . -t robot-browser
$ docker run --rm -it -v "/path/to/testfolder:/opt/robotframework/tests" robot-browser:latest
[ WARN ] Keyword 'Take Screenshot' could not be run on failure:
Error: Tried to take screenshot, but no page was open.
Example Test                                                          | FAIL |
Error: browserType.launch: Protocol error (Browser.getVersion): Browser closed.
==================== Browser output: ====================
<launching> /usr/local/lib/python3.9/site-packages/Browser/wrapper/node_modules/playwright/.local-browsers/chromium-901522/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --dis
able-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --d
isable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose --allow-pre-commit-input --disable-hang-monitor --di
sable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=bas
ic --use-mock-keychain --no-service-autorun --user-data-dir=/tmp/playwright_chromiumdev_profile-MckehO --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPoi
nterType=4,availablePointerTypes=4 --no-sandbox --no-startup-window
    [ Message content over the limit has been removed. ]
...e=basic --use-mock-keychain --no-service-autorun --user-data-dir=/tmp/playwright_chromiumdev_profile-MckehO --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,pr
imaryPointerType=4,availablePointerTypes=4 --no-sandbox --no-startup-window
<launched> pid=64
[pid=64][err] /usr/local/lib/python3.9/site-packages/Browser/wrapper/node_modules/playwright/.local-browsers/chromium-901522/chrome-linux/chrome: /usr/lib/ no version information available (required by /usr/local/lib/pytho
[pid=64][err] /usr/local/lib/python3.9/site-packages/Browser/wrapper/node_modules/playwright/.local-browsers/chromium-901522/chrome-linux/chrome: /usr/lib/ no version information available (required by /usr/local/lib/pytho
[pid=64][err] /usr/local/lib/python3.9/site-packages/Browser/wrapper/node_modules/playwright/.local-browsers/chromium-901522/chrome-linux/chrome: Relink `/usr/lib/' with `/usr/glibc-compat/lib/' for IFUNC symbol `strc
Tests.Test                                                            | FAIL |
1 test, 0 passed, 1 failed
Tests                                                                 | FAIL |
1 test, 0 passed, 1 failed
Output:  /opt/robotframework/reports/output.xml
Log:     /opt/robotframework/reports/log.html
Report:  /opt/robotframework/reports/report.html

On Browser upstream and to my understanding even at Playwright only debian based variants are tested. In general I can offer no help on even getting the browsers to run in Alpine.

Also as an aside, even in general for python projects oftentimes debian based images can be faster / slimmer than alpine based. Building python packages inside alpine slows down the container building quite a lot. See The best Docker base image for your Python application (February 2021) for some (a bit old) examples.

So if you can, please try a debian / ubuntu based base-image, if you can’t, lets hope that somebody else has experience getting the library run on Alpine.

Well with much searching and pulling bits of info from various websites I did manage to get it *working*

There was a big BUT though, you need to add the --no-sandbox option to chrome, I can’t remember which one of these worked, but it was one of them, in the end I never used it:

# ${BROWSER}		Headless Chrome		--no-sandbox
# ${BROWSER_OPT}	options=add_argument("--no-sandbox")

I did this quite a while ago so the versions are quite old and I had trouble getting it to work with newer versions too, in the end I gave up with it as the --no-sandbox was a deal breaker for my purposes (I was wanting to create rfswarm-agent docker images to support >10 robots)

If you still want to continue this is what I had working, from what I understand the trick was setting the screen resolution and using Xvfb to create a virtual xwindows environment so that the browser could run:


FROM python:3.7-alpine3.9

    chromium \
    chromium-chromedriver \
    udev \
    xvfb \

COPY requirements.txt /tmp/requirements.txt
COPY /opt/bin/

RUN apk update ;\
    apk add --no-cache ${DEPS} ;\
    pip install --no-cache-dir -r /tmp/requirements.txt ;\
    # Chrome requires docker to have cap_add: SYS_ADMIN if sandbox is on.
    # Disabling sandbox and gpu as default.
    sed -i "s/self._arguments\ =\ \[\]/self._arguments\ =\ \['--no-sandbox',\ '--disable-gpu'\]/" $(python -c "import site; print(site.getsitepackages()[0])")/selenium/webdriver/chrome/ ;\
    # List packages and python modules installed
    apk info -vv | sort ;\
    pip freeze ;\
    # Cleanup
    rm -rf /var/cache/apk/* /tmp/requirements.txt

ENTRYPOINT [ "/opt/bin/" ]


Xvfb :99 -screen 0 $GEOMETRY &
export DISPLAY=:99

robot "$@"



Hopefully you find this useful,


1 Like

Thanks for the help. The base image in question (ppodgorsek/robot-framework) already has Chrome and Firefox there, so the problem is only with making the Browser library itself working. Maybe worth looking though whether switching to one of the existing Debian-based images would make things easier while not breaking anything in our test environments.

As far as I remember, the browsers installed in that image are required for Selenium library.

Browser Library does not require pre installed browsers, as far as I know.

Hi Matti,

From the image you had I don’t see anywhere where you are setting a screen resolution or (virtual) display, in order to open a browser (even in headless mode) seems to require some kind of display driver. perhaps you can adapt the from my example to make yours work.


This is the entrypoint for the base image (as well as the one I derived from it) docker-robot-framework/ at master · ppodgorsek/docker-robot-framework · GitHub . It does use xvfb and sets the screen size too.

I noticed my baseimage has added the Browser library in their commits since last release. Tried it without success. Filed a bug report to them. If it doesn’t seem to get resolved I’ll start porting my own derived image to debian. Or maybe start from an existing robot image that is already debian based.

@makimat Did you manage to port your image to debian based already? If so, did the image grow huge?
I guess I will need to do the same as I need to get Browser Library with some of my own Node.js stuff into the same image, and Alpine does not seem to work well with the browsers, as also Playwright guys are saying: Docker | Playwright

It’s still on my todo-list, didn’t yet give it a try. Would be nice to share the effort somehow if possible.

I will need to try it out soon. I’ll come back if/when I find a solution, or if there is something where I could use some help.

1 Like

After trying multiple different solutions, and checking the size of each image, I ended up using the marketsquare/robotframework-browser image as the basis (it is Ubuntu Focal based) for my image. On that image I had to update node to latest stable (it was some 12.x version), and also had to do “npx playwright install-deps” to get tests running also on webkit. Chromium and Firefox worked even without the playwright deps installation but for some reason webkit didn’t.

In addition to my nodejs server application I also added TestCafe and separately browsers (Firefox and Chrome) to my image as I needed those too, and got it working with some tweaks. The image size with all my stuff is now 3.19GB, of which maybe 3GB is something else than my own nodejs app. The Docker image I made based on pure Alpine (alpine:edge) was 3.27GB, essentially with the same content but Playwright/Browser library not working.

So, as a summary, I decided not to waste more time on trying to figure out how to make the image size smaller by using Alpine as it would probably not benefit me that much either. Node, Python and browser packages just are so big that the image size will grow so much anyhow.

One trial I made was based on bitnami/node:14, which is “only” 594MB but adding all my required stuff to that got it to 1.85GB. But, I did not yet get Playwright/Browser library working in that image. @makimat, if you want to try out something based on that I can share you the Dockerfile. Without my own stuff, only RF and browser lib added and initialized, the image size is 952MB but like said, it does not work. When trying to run a Robot case with Browser library, it complains on not finding the browser, and that I need to run npx playwright install, which does not succeed because of error Cannot find module '/root/.npm/_npx/331/lib/node_modules/playwright/install.js'

The underlying Playwright is strict on supported Linux distro and officially they support only Ubuntu out of the box. It is possible get the Playwright working on other distro, but then one needs to figure out, which dependencies they need to install for Playwright (which is not documented anywhere, last I looked.)

I would be happy to see your Dockerfile @ssallmen, seems like you’ve had good progress in getting things work. I don’t mind the image being Ubuntu-based, very likely an Alpine-based would grow big too, for the reasons you mentioned.

We could even consider putting out a shared github repo for this image if it seems like we need to maintain the various versions of apps and libraries in it.

Here below is the Dockerfile contents where I have updated the Node version to be the latest stable, and have also TestCafe installation, and where Browser Library works.

If you strip the TestCafe part away, you can see that it does not have very much anything else but the update of Node.js. The base image itself (marketsquare/robotframework-browser) is good and works as such, if you just need Robot with Browser Library. You can of course use that image as your base and in your own Dockerfile add other Robot libraries as you wish.
The reason why I have multiple test automation tools (actually not just Robot and Testcafe) in my container image is that I am building a system which supports multiple tools and has a unified way to run the tests and report test results to Jira. The tests are provided via the volume in /myStuff/tests and reports from tests will be available through the /myStuff/results volume.

FROM marketsquare/robotframework-browser
WORKDIR /myStuff
USER root

# Update Node.js to latest stable
RUN rm /etc/apt/sources.list.d/nodesource.list
ENV NODE_PATH=/usr/local/lib/node_modules:${NODE_PATH}
RUN npm cache clean -f && \
 npm install -g n && \
 n stable

# Robot Framework/Playwright begins
RUN npx playwright install-deps
# Robot Framework/Playwright ends

# TestCafe begins
ARG testCafeVersion
ENV TESTCAFE_PACKAGE_ID=v${testCafeVersion:-1.16.0}.tar.gz

# Install all other dependencies but Google Chrome (Chrome requires special installation in Ubuntu Focal because of new snap requirement of the default chromium package)
RUN apt-get update && \
 apt-get install -y \
 firefox xvfb dbus fonts-freefont-ttf fluxbox procps tzdata
# Install Chrome
RUN curl -LO && \
 apt-get install -y ./google-chrome-stable_current_amd64.deb && \
 rm google-chrome-stable_current_amd64.deb

RUN npm install -g testcafe && \
 npm cache clean --force
RUN script_file=$(tar -ztvf /opt/testcafe/${TESTCAFE_PACKAGE_ID} | grep docker/ | awk '{print $6}') && \
 tar -zxvf /opt/testcafe/${TESTCAFE_PACKAGE_ID} -C /usr/bin $script_file --strip-components 2 && \
 sed -i 's#/usr/lib/#/usr/local/lib/#g' /usr/bin/ && \
 chmod a+x /usr/bin/ && \
 rm /opt/testcafe/${TESTCAFE_PACKAGE_ID}
EXPOSE 1337 1338
# TestCafe ends

RUN chown -R pwuser /myStuff
USER pwuser
RUN mkdir results tests
VOLUME /myStuff/results
VOLUME /myStuff/tests
1 Like

Here is the other trial using bitnami/node:14 as the base image.

FROM bitnami/node:14
WORKDIR /myStuff
RUN install_packages python3 xvfb python3-dev libssl-dev libffi-dev
RUN ln -sf python3 /usr/bin/python && \
 python3 -m ensurepip && \
 pip3 install --no-cache --upgrade pip && \
 pip3 install --no-cache setuptools && \
 pip3 install --no-cache robotframework robotframework-browser
RUN rfbrowser init

But, as I said, the Playwright in that container will not work, and actually the rfbrowser init fails. I use xvfb-run to run the tests, just like in the other container.

1 Like


i have i think a very similar problem with the robotframework-browser library. I don’t get to find a way to install it on my image, based on ubuntu18.04, neither to install the library on my local machine, running Ubuntu as well.

ERROR: Could not find a version that satisfies the requirement robotframework-browser (from versions: none)
ERROR: No matching distribution found for robotframework-browser

Here’s my complete dockerfile in case:

FROM ubuntu:18.04

USER root

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    apt-get -qq -y install curl && \
    apt-get update -y  && \
    apt-get install -y build-essential python3.6 python3.6-dev python3-pip && \
    python3.6 -m pip install pip --upgrade && \
    apt-get install -y libgconf-2-4

RUN apt-get update && \
    apt-get install -y --no-install-recommends libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libnotify4 libxslt1.1 libevent-2.1-6 libgles2 libxcomposite1 libatk1.0-0 libatk-bridge2.0-0 libepoxy0 libgtk-3-0 libharfbuzz-icu0 # buildkit
RUN apt-get update && \
    apt-get install -y --no-install-recommends libgstreamer-gl1.0-0 libgstreamer-plugins-bad1.0-0 gstreamer1.0-plugins-good gstreamer1.0-libav # buildkit
RUN apt-get update && \
    apt-get install -y --no-install-recommends libnss3 libxss1 libasound2 fonts-noto-color-emoji libxtst6           # buildkit
RUN apt-get update && \
    apt-get install -y --no-install-recommends libdbus-glib-1-2 libxt6 # buildkit
RUN apt-get update && \
    apt-get install -y --no-install-recommends ffmpeg # buildkit
RUN groupadd -r pwuser && \
    useradd -r -g pwuser -G audio,video pwuser && \
    mkdir -p /home/pwuser/Downloads && \
    chown -R pwuser:pwuser /home/pwuser # buildkit
RUN apt-get update && \
    apt-get install -y --no-install-recommends xvfb # buildkit
RUN curl -fsSL | bash -
RUN apt-get install -y nodejs
RUN npm install -g playwright

USER pwuser
#Install the required libraries
RUN pip --version
RUN pip3 --version
RUN pip install --user robotframework
RUN pip install --user robotframework-sshlibrary
RUN pip install --user robotframework-seleniumlibrary
RUN pip install --user robotframework-requests
RUN pip install --user pyperclip
RUN pip install --user robotframework-xvfb
RUN pip install --user robotframework-csvlib
RUN pip install --user robotframework-browser

Hope someone got to install that correctly and has a suggestion for me! :slight_smile:

@fede-green, Browser library supports only python 3.7 or newer but you have 3.6.

Thanks a lot!!! it fixed my another issue. :grinning: