# Installing and using browser on alpine-based docker images

**URL:** <https://forum.robotframework.org/t/installing-and-using-browser-on-alpine-based-docker-images/2338>\
**Category:** Browser\
**Created:** [27 August 2021 13:03 UTC](https://forum.robotframework.org/t/installing-and-using-browser-on-alpine-based-docker-images/2338 "2021-08-27T13:03:01Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [28 August 2021 00:42 UTC](https://forum.robotframework.org/t/installing-and-using-browser-on-alpine-based-docker-images/2338/3 "2021-08-28T00:42:21Z")

</div>

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:

```python
# ${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:

Dockerfile:

```python
FROM python:3.7-alpine3.9

ENV SCREEN_WIDTH 1280
ENV SCREEN_HEIGHT 720
ENV SCREEN_DEPTH 16
ENV DEPS="\
    chromium \
    chromium-chromedriver \
    udev \
    xvfb \
"

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

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/options.py ;\
    # List packages and python modules installed
    apk info -vv | sort ;\
    pip freeze ;\
    # Cleanup
    rm -rf /var/cache/apk/* /tmp/requirements.txt

ENTRYPOINT ["/opt/bin/entry_point.sh"]

```

entry\_point.sh:

```python
#!/bin/sh

GEOMETRY="${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH}"
Xvfb :99 -screen 0 $GEOMETRY &
export DISPLAY=:99

robot "$@"

```

requirements.txt

```python
robotframework==3.1.1
robotframework-selenium2library==3.0.0
robotframework-seleniumlibrary==3.3.1
selenium==3.141.0

```

Hopefully you find this useful,

Dave.

---

_[View the full topic](https://forum.robotframework.org/t/installing-and-using-browser-on-alpine-based-docker-images/2338)._
