Graphical apps in Docker

Sometimes we get tools that only run in specific distributions of linux, or that need specific libraries we don't have in the current installed release, or we just want to keep our system clean.

By using Docker we can fulfill all those goals. For backend appliccations it already is done very often but it is also possible to use Docker for graphical apps.

For example:


FROM centos
RUN yum install -y xeyes
CMD ["/usr/bin/xeyes"]

Create the docker image:

docker build -t xeyes:1.0 .

Run the image:

docker run --rm -it \
    --env="DISPLAY" \
    --net=host \
    --volume="${HOME}/.Xauthority:/root/.Xauthority:rw" \