Management system kotaniemi docker aims to ensure that the processes worked without a graphical interface. However, sometimes it is necessary to use it not on purpose, for example, run applications, which in normal mode will work in the mode without the interface, but for debugging it is necessary to look at what they are doing and what output.
In this small article we will understand how to run GUI application in a Docker operating systems Linux. We will connect our main X server to the container.
Graphical applications in Docker
The first thing we need to do a little change for the host, otherwise the host will not allow the container application to connect to the X server. Create a file /tmp/docker.xauth:
And then put data into it for authentication:
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f touch /tmp/docker.xauth nmerge -
These lines can be added to ~/.xinitrc, so that the authentication file was created automatically when you start the X server:
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
You are now ready to run the docker container with the gui. In the container we will Trimontium this file, the UNIX socket to the X server and pass the variables that will help the apps in the container this is all to find. For example start gimp:
docker run --rm-ti-v /tmp/.X11-unix:/tmp/.X11-unix -v /tmp/docker.xauth:/tmp/docker.xauth -e DISPLAY=unix$DISPLAY -e XAUTHORITY=/tmp/docker.xauth jamesnetherton/gimp
If you want to run more complex software, such as Google Chrome browser, then you need to connect and support hardware acceleration of video and sound:
docker run --rm-ti-v /tmp/.X11-unix:/tmp/.X11-unix -v /tmp/docker.xauth:/tmp/docker.xauth -e DISPLAY=unix$DISPLAY -e XAUTHORITY=/tmp/docker.xauth --device /dev/dri/dev/dri --device /dev/sni/dev/sni dmitryrck/google-chrome
In this article, we briefly dismantled how can I run graphical applications Docker. The GUI is a rather unusual task, but it can be solved.