In Linux(Ubutu 14.04)
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/dev && \ echo "dev:x:${uid}:${gid}:Developer,,,:/home/dev:/bin/bash" >> /etc/passwd && \ echo "dev:x:${uid}:" >> /etc/group && \ echo "dev ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/dev && \ chmod 0440 /etc/sudoers.d/dev && \ chown ${uid}:${gid} -R /home/dev USER dev ENV HOME /home/dev CMD /usr/bin/firefoxIn Linux(Ubutu 16.04 and later)
FROM ubuntu:16.04 RUN apt-get update && apt-get install -y firefox ENV USERNAME dev ENV HOME /home/$USERNAME RUN useradd -m $USERNAME && \ echo "$USERNAME:$USERNAME" | chpasswd && \ usermod --shell /bin/bash $USERNAME && \ usermod -aG sudo $USERNAME && \ mkdir /etc/sudoers.d && \ echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \ chmod 0440 /etc/sudoers.d/$USERNAME && \ # Replace 1000 with your user/group id usermod --uid 1000 $USERNAME && \ groupmod --gid 1000 $USERNAME RUN apt-get install -y sudo USER dev ENV HOME /home/dev CMD /usr/bin/firefox
Host machine(Linux)
xhost +
Run docker cmd
docker run [--rm [-it]|-d] \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e DISPLAY \ imagename [cmd]