Skip to content

Instantly share code, notes, and snippets.

@dmouse
Last active June 2, 2022 20:52
Show Gist options
  • Save dmouse/e76ce3d8dde00fe496da to your computer and use it in GitHub Desktop.
Save dmouse/e76ce3d8dde00fe496da to your computer and use it in GitHub Desktop.
Run Firefox or Google Chrome into a Docker container | based on http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
FROM ubuntu:14.04
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
chmod 0440 /etc/sudoers.d/developer && \
chown ${uid}:${gid} -R /home/developer
RUN apt-get update && apt-get install -y firefox wget
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update
RUN apt-get install google-chrome-stable dbus-x11 packagekit-gtk3-module libcanberra-gtk-module -y
USER developer
ENV HOME /home/developer
CMD dbus-daemon --system --fork && /usr/bin/firefox
docker build -t browser .
docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix browser
docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix browser google-chrome
@haloted
Copy link

haloted commented Sep 1, 2019

Is there a way to make this work with later versions of ubuntu, say 16.04 or 18.04? Getting error stuck on line /sudoers.d/ directory doesn't exist?

@jiahut
Copy link

jiahut commented Jul 18, 2020

you can visit chrome-docker for help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment