Running X11 applications with Docker

Amalfitano
1 min readJun 5, 2019

--

Sometimes as sysadmin or developer, you have to run some GUI-based application in computers that are not yours, or simply run it as first-run (avoiding cache, for example).

This knowledge comes from Docker in practice. Thanks folks for these amazing book!

For this example, I'm going to use lyonn (id 1000, group lyonn (1000)) user, please, replace it with your own.

Dockefile

FROM ubuntu:14.04

RUN apt-get update
RUN apt-get install -y firefox
RUN groupadd -g 1000 lyonn
RUN useradd -d /home/lyonn -s /bin/bash -m lyonn -u 1000 -g 1000
USER lyonn
ENV HOME /home/lyonn
CMD /usr/bin/firefox

Build the image

docker build -t gui .

Run the container

docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -h $HOSTNAME -v $HOME/.Xauthority:/home/lyonn/.Xauthority gui

Viola!

Firefox running

--

--