X11 forwarding using docker desktop for linux

I am attempting to run a docker container in docker desktop for linux that requires access to my host machine’s display. The docker image that the container is running on is based on the PX4 flight controller and runs a software-in-the-loop simulation using a simulation engine called gazebo. The name of the image is px4io/px4-dev-ros-noetic and I have cloned the PX4 firmware into my hosts ~/PX4-Autopilot directory.

I am able to run the simulation with no display issues using docker CLI with the “docker run” command. On my host machine terminal, I first run:

xhost +

And proceed with:

docker run -it --privileged \
-v ~/PX4-Autopilot:/src/PX4-Autopilot/:rw \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
-e DISPLAY=$DISPLAY \
--net=host \
--user root \
--name=px4-ros px4io/px4-dev-ros-noetic bash

With the above command my container runs and my simulation appears on my host display. I would like to repeat these steps using docker desktop for linux. The reason for this is that colleagues are working on MacOS and access all docker-related actions via docker desktop for mac. My thinking is that working on docker desktop for linux will facilitate a more seamless development process among all of us.

When running my containers in docker desktop for linux, and running the container with the above docker run command, I keep running into the error: unable to open display when my simulation GUI attempts to launch.

I realize that docker desktop is launching my containers in a virtual machine and this is likely resulting in my display issues, but I have been unable to hone in on a solution to successfully allow my container in docker desktop to access my host’s display.

Any advice on a fix for my issue?

I’ve attempted to play with the -e DISPLAY variable in the docker run command, setting -e DISPLAY to my host’s IP address, but the issue persists.

I am afraid, it will not work with Docker Destop, as it runs its docker engine in a utility vm that has no access to x11 unix domain socket. So reverting to Docker-CE is the only chance I can see right now.