Is it possible to display X11 through socketing in Docker Desktop for Linux?

Hi, I am trying to get X11 windows on the host from Docker Containers without ssh forwarding or VNC. (Other GUI apps by GTK don’t work either).

I am on a Ubuntu 22.04 host machine and I tried very basic ubuntu images and basic X11 apps (e.g. xclock) on top.

I’ve tried adding flags --net=host --privileged -e DISPLAY and -v "/tmp/.X11-unix:/tmp/.X11-unix:rw". I also disabled the security check by xhost + (although it is not secure); alternatively, I did binding .Xauthority files.

Still, I get “Can’t open display :1” errors, is it possible to do this through Docker Desktop for Linux? Is QEMU/KVM layer preventing network connection? Should I switch back to Docker Engine, even though Desktop is becoming the standard?
Thanks.

Docker Desktop is NOT becoming a standard, at least not the way you might think. It can help developers in some cases, but it is still a special environment using virtualization and everything is running in the VM (including Docker CE). Think of it as a remote server. Docker Desktop just helps you configure the client-server connection automatically.

On Windows or macOS, Docker Desktop is the easiest way to run Linux containers, but Docker Desktop for Linux exists because Docker tries to give you the same exprience on each platform. It will never be perfect, so there will always be some things for which you will need Docker CE and not Docker Desktop.

It is possible that I won’t be popular saying this :slight_smile: but my goal is to help you get the best experience, so my recommendation is that you use Docker CE on Linux distributions unless you need a feature which exists in Docker Desktop. This is the way to get the most out of Docker on Linux.

To be fair, I have to add that Docker Desktop can also help you limit the usable resources, so if a container has a bug and starts to use too much memory, it will not affect your host even if you didn’t set memory limit on the container.

I also like that Docker Desktop has more and more extensions so you can learn about tools that you would not hear about otherwise and it makes easier to use those tools, but it adds complexity and some issues will be harder to solve or even impossible.

I have Docker Desktop on my macOS and I had issues, but recently it works pretty well. I feel like v4.15 became even faster and I have Docker Desktop for Linux to learn about it and help when someone needs it, but I usually use Docker CE on Linux.

1 Like

Thank you @rimelek for the honest and clear explanation :+1: My intention was to deal with only one service (either Desktop or CE) to keep things neat. But it seems you are right about Desktop:

So, knowing about what kind of functionalities exist in the “Docker world” is valuable. This is very easy to get with Desktop. As a downside, it comes with more complex issues (probably due to an extra virtualization layer etc.).

By the way, your valid points (resource limiting, similar experience across platforms) are also well-stated here, in case someone else needs to check. In fact, this page was the reason, why I had the idea of the Desktop becoming the standard.

All in all, just before reading your reply, I decided to go with dual installation (CE alongside Desktop). They are isolated from each other and it is straightforward to switch between by docker context use <...>. GUI applications work seamlessly with CE.

Still, I’d like to hear a solution if someone happens to figure out X11 socketing for Desktop.

Cheers!

Hi @volkbay,

i managed to display the gui from a linux gui container in docker desktop under windows using VcXsrv (X11 Server under Windows) and runing the docker container with the folowing parameter: -e DISPLAY=host.docker.internal:0

Does this answer your question?

Cheers