Score:2

Problem with GUI apps: Cannot open display [Docker Desktop, Ubuntu Host, Ubuntu based image]

ae flag

I'm having problem with opening any GUI application in a running container. In short, I always get similar "cannot open display" errors from different applications.

Platform

Host : Ubuntu 22.04

Docker : Docker Desktop 4.15

Image : kalibr (some Ubuntu 20.04 and ROS Noetic based image) [Extra note: I've tried running simple xclock on a plain ubuntu:latest image, as well]

Run Command

docker run -it --network=host -e DISPLAY -v "/tmp/.X11-unix:/tmp/.X11-unix:rw" -v <another bind mount> <image name>

I've tried also:

  • xhost +local:root, xhost +local:docker, even xhost + before running container
  • --privileged
  • --runtime=runc
  • DISPLAY=127.0.1.1:1 (i.e. my host IP)
  • DISPLAY=unix$DISPLAY

Extra Info

Some env vars in the container: HOSTNAME=docker-desktop DISPLAY=:1 QT_X11_NO_MITSHM=1

Can QEMU/KVM virtualization be the root of the problem, as it is Docker Desktop (not Docker Engine only) ?

Cheers

Alejandro avatar
mz flag
The issue may reside on trying to virtualize a whole system itself, remember Docker is not a Hypervisor and is not meant to run a Desktop environment, it is just for containerized applications and microservices. Yes, it is possible to achieve that, but don't expect a fluent nor stable run. Docker Desktop is not for virtualizing Desktop environments as some may think, it is just a GUI application for managing your containers without having to deal with the CLI, pretty similar to Portainer.
zwets avatar
us flag
Does this answer your question? [Docker, X11 fails to open display](https://askubuntu.com/questions/1201103/docker-x11-fails-to-open-display)
volkbay avatar
ae flag
@Alejandro thanks ! Sorry I am new to Docker, am I actually emulating whole GNOME ? Because it is not what I am after. I suppose "window management" level should be enough rather than a complete desktop env. What I need is to observe a simple output plot from `rosrun` or get an `imshow` out of OpenCV from a Python script. Or simply opening an xterm terminal window. I can't do neither, all would give me "cannot open display".
volkbay avatar
ae flag
@zwets thanks, still, I checked that entry before posting here. I agree that `--net=host` flag is necessary and already included in my command.
Alejandro avatar
mz flag
If you just need an output of a python script (and not use any GUI apps) on a terminal, you can try to use an image of an OS, such as [Debian][1] or [Busybox][3] and install python using CLI to then run your script, or simply run a container of [Python][2] itself. Docker can be a bit confusing at first for new users, I recommend you have a look at some tutorials on Youtube so you have some understanding on how you can use it before deploying your development environment. [1]: https://hub.docker.com/_/debian [2]: https://hub.docker.com/_/busybox [3]: https://hub.docker.com/_/python
Alejandro avatar
mz flag
About your question of emulating whole GNOME... I do not know what your set up looks like, but regular containers do not deploy GUI, as it is intended to run the core of an app or service. You may serve some services such as a website which you'll access from the browser, but you will not virtualize a system like a Hypervisor will do. Have a look at differences between Hypervisors and Docker.
volkbay avatar
ae flag
Thanks for the links and explanations @Alejandro. Yet, no luck. After looking up, I am pretty convinced that I need only Docker containerization, not Hypervisors. And commands I tried to run, only sockets X11 window management. There is no desktop virtualization. I also tested plain Debian with a simple X11 app on top (`xeyes`), as there are many tutorials doing that. No change :/
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.