ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'm unsure of your setup, but I was able to solve a similar issue with uninstalling Docker Desktop and installing Docker CE. I have Ubuntu 22 as my host OS and apparently Docker Desktop on Ubuntu runs through a VM that doesn't properly forward graphics access. This thread covers the issue as related to USB connections.

For additional reference: I did not need to run the command xhost +local:root but did need to run xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f /tmp/.docker.xauth nmerge - && chmod 644 /tmp/.docker.xauth. I'm working with Gazebo Fortress and ROS2 Humble.

I used the following compose file to launch the container:

version: '3.4'

networks:
  ros_net:
    driver: bridge

services:
  gazebo:
    image: [your gazebo image]
    command: ign gazebo empty.sdf
    environment:
      - DISPLAY=${DISPLAY}
      - QT_X11_NO_MITSHM=1    
      - QT_DEBUG_PLUGINS=1
      - XAUTHORITY=/tmp/.docker.xauth  
    networks:
      - ros_net      
    volumes:
      - ~/.gazebo:/root/.gazebo/:rw   
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
      - /tmp/.docker.xauth:/tmp/.docker.xauth:rw" 
      - "/dev/dri:/dev/dri"