

Since the Docker daemon runs as root, Docker containers (in general!) now can use the current users display. This can be done by executing the following command: xhost local:rootĪfter execution, during the session, root is allowed to use the current users display. The Docker container needs to be allowed to present its screen on the Docker host. For example docker run -env DISPLAY=$DISPLAY containername Allow access to the display In a Docker command (when not using docker-compose), you would do this with the -e flag or with –env. The environment indicates the host DISPLAY variable is passed as DISPLAY variable to the container. You can do this by providing it in a docker-compose.yml file. This makes it easier to run containers in a quick and reproducible way and avoids long command lines. docker-compose describes the environment/volume mappings/port mappings and other things of docker containers. In order to make the display available, you can pass the DISPLAY environment variable to the container. The container needs to be aware of the display to use. In order to run a GUI application from a Docker container and display its GUI on the host OS, several steps are needed Which display to use? Due to (several) security concerns, this is not recommended in a production environment. The code (Dockerfile and docker-compose.yml) can also be found here. For this I will use Spring Tool Suite as an example. I’ll explain several of the issues you might encounter and how to solve them. Running GUI applications like for example an IDE from a Docker container, can be challenging. Running an application within a Docker container helps in isolating the application from the host OS.
