0

I wrote some Java desktop applications and thought I'd run them with Docker to learn about containers.

I got the Java applications into a Docker container with an ubuntu image. And that's when I realized that I needed to give Docker the ability to access my DISPLAY variable in order for the GUI to work / get access to my computer's I/O. Once I got that connected, I could run the docker container and see the GUI pop up on my computer screen.

Here's where I start getting confused. If I run a desktop GUI in say, VirtualBox, I can see the gui in the virtual machine; it's on the virtual computer. And then there is something smart that connects the vm I/O to my local machine's I/O. That makes sense to me.

But how is Docker getting the GUI back onto my actual computer? When I run the container, I can see the GUI on my actual computer (not in a vm like virtualbox). But how does the GUI itself render on the host machine? When I share the I/O with my host machine, does that give Docker the permission to send the GUI files back to the host machine to display the GUI? Or did I basically create a virtual machine when I created the container with the ubuntu image?

migrated from serverfault.com Mar 11 at 14:26

This question came from our site for system and network administrators.

3

If you're on Linux, mount /tmp/.X11-unix in your docker (option in launch command : -v /tmp/.X11-unix:/tmp/.X11-unix) and you will be able to display any type of GUI without any other option. Sharing this file with the docker allow any type of GUI.

If you don't want to do this then, you can type an xhost+ command as Linux regular user, then from the Docker use export DISPLAY=IP:0.0 (or whatever needed but IP cannot be 127.0.0.1 even in local).

xhost+ allow any host, export DISPLAY share the display on the "remote" machine.

If you're running the docker on Windows localhost, all ports are basically opened but you need a specific Xserver in order to display Ubuntu on windows Desktop (VcXsrv is your friend as it's a specific X Server compiled with Visual C++ 2012) and command export DISPLAY=IP:0.0 should be issued before launching GUI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.