Skip to content

Instantly share code, notes, and snippets.

@madratman
Last active April 17, 2017 17:58
Show Gist options
  • Save madratman/9becd642342ae75f7126398ce8a83cf5 to your computer and use it in GitHub Desktop.
Save madratman/9becd642342ae75f7126398ce8a83cf5 to your computer and use it in GitHub Desktop.
docker with X transfer

Add this to dockerfile:

RUN apt-get update RUN apt-get install -qqy x11-apps ENV DISPLAY :0

Authorise current user first in host: xhost +si:localuser:$USER

docker run -it --rm
-e DISPLAY=$DISPLAY
-v /tmp/.X11-unix:/tmp/.X11-unix
imagename

Alternative: FROM ubuntu:14.04 RUN apt-get update && apt-get install -y firefox

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 USER developer ENV HOME /home/developer CMD /usr/bin/firefox

Ref: http://stackoverflow.com/questions/16296753/can-you-run-gui-apps-in-a-docker-container

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