firefox in docker and ssh tunnel

How to run firefox inside a docker container?

firefox in docker

Adapted from [1] for debian:jessie-slim:

FROM debian:jessie-slim

RUN apt-get update && \
        apt-get install -y firefox-esr && \
        apt-get clean

RUN groupadd --gid 1000 user && \
        useradd --uid 1000 --gid 1000 --create-home user

USER user
CMD /usr/bin/firefox-esr

Build the image:

sudo docker build -t firefox .

Forwarding X over Unix socket:

xhost +local:
sudo docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix firefox

ssh tunnel

ssh -f user@myserver.net -L 80:reddit.com:80 -N

If you edit /etc/hosts in the container to make reddit.com localhost.

Result

References

[1]DinoTools, "Firefox im Docker Container", https://www.dinotools.de/2015/12/02/firefox-im-docker-container/

More

[2]Bo Jeanes, "The Black Magic Of SSH", https://vimeo.com/54505525