Cannot open GUI in Docker container

I am not sure what I am doing wrong. I am trying to get a Gazebo to launch gazebo in a docker container. It was working last week then I am not sure what I did, and now I can no longer get the gazebo to launch in the container. I have validated that I am passing in the X11 server. I am running the following command and getting the following outputs. I think that I did something with SSH, I was working on a jetson container before everything broke. I have been following this post here but it is not working.

I am not sure what is going on. Does anyone know what I am doing wrong?

nathaniel@nathaniel-WS:~$ docker run -ti -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix my_build
root@cedd32503251:/turtlebot3_ws# gazebo --verbose
Gazebo multi-robot simulator, version 11.11.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
Gazebo multi-robot simulator, version 11.11.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 172.17.0.2
[Err] [RenderEngine.cc:749] Can't open display: :1
[Wrn] [RenderEngine.cc:89] Unable to create X window. Rendering will be disabled
[Wrn] [RenderEngine.cc:292] Cannot initialize render engine since render path type is NONE. Ignore this warning ifrendering has been turned off on purpose.
[Msg] Loading world file [/usr/share/gazebo-11/worlds/empty.world]
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 172.17.0.2
[Wrn] [GuiIface.cc:298] Couldn't locate specified .ini. Creating file at "/root/.gazebo/gui.ini"
[Err] [RenderEngine.cc:749] Can't open display: :1
[Wrn] [RenderEngine.cc:89] Unable to create X window. Rendering will be disabled
[Wrn] [RenderEngine.cc:292] Cannot initialize render engine since render path type is NONE. Ignore this warning ifrendering has been turned off on purpose.
[Wrn] [GuiIface.cc:120] could not connect to display :1
[Msg] Could not load the Qt platform plugin "xcb" in "" even though it was found.
[Err] [GuiIface.cc:124] This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Let’s start with the fact that you opened the topic in Docker Desktop for Linux. Do you really use Docker Desktop?

Yes I do. is that causing something to break? why is using Docker Desktop a problem?

People often open their Linux related questions in this category and Docker Desktop and Docker Engine is different so it is very important to know which one you use. I don’t know how it worked for you before, but as far as I know, you can’t mount unix sockets from the host to Docker Desktop. Docker Desktop runs the daemon in a virtual machine and mounting unix sockets is not supported.

Once I demonstrated how using GUI in Docker Desktop possible but I ran a container which had the GUI app (firefox) and connected to it through a browser based RDP connection.

https://dev.to/rimelek/docker-network-and-network-namespaces-in-practice-5h9#running-a-web-browser-in-a-net-namespace-in-a-vm-docker-desktop

Update:

I think there is another way too, but I can’t tell you the final solution now. I just remember that once I forwarded my display to an IP address on my Mac, because it didn’t work through SSH.

I found this topic, but it’s not about Docker

I did a bit more testing and it turns out I cannot ssh or ping my container from my host machine either. I think that this is related but I am not sure how to fix it

Also I am not running a VM. Ubuntu is my native OS.

You just stated you use Docker Desktop. Whether you want a VM or not, there will be even on Linux. This is how Docker Desktop works.

SSH or ping? How? if it is really Docker Desktop, you can’t access the container IP without port forward if that’s what you tried. Regarding SSH, I don’t think you need to SSH into the container. The link I shared was just one I could quickly find, but not for Docker. I just wanted to share it as an idea and unfortunately it might be useless :slight_smile: I just hope it is not. My point was that the you could have an IP or hostname in the DISPLAY variable.

I see you moved the topic to the Docker Engine category so I’m confused. Is it Docker Desktop or Docker Engine?

Sorry for the confusion. I am running the containers using the command line. I am just using the Docker GUI to look at what containers I that I am running. I don’t think my problem has anything to do with the Desktop software.

And the confusion continues. Docker Engine has no Docker GUI. If you use the GUI of Docker Desktop you use Docker Desktop and the Docker daemon in its VM. Doesn’t matter if you use the command line. The client just connects to the daemon inside the virtual machine. Docker Desktop can’t see the Docker Engine outside the VM.

Did you install Docker Engine and Docker Desktop as well and maybe you changed context to use the GUI?

Try:

docker context ls

and

docker context use default

and try the X11 forward again.

So after uninstalling everything, both the engine and desktop. i was able to get pass in the X11 and get graphical output. I have yet to get it working with the docker-desktop. I am going to try that next