Running Ignition Gazebo headless in Docker container

Hi - new Ignition Gazebo user here. I have a docker image that is built from a ROS Foxy base image. In this image, I also install ignition-citadel (need to use this version). I tested that everything is working by adding VNC capability to the image, starting the container and running the demos, etc., but I ultimately want to do this headless. When I remove the VNC capability, I receive error messages about lacking a display and the process (i.e. one of the demos) appears to stop. Is it possible to suppress these messages and proceed without some sort of display output? I’d appreciate any advice/help. Thanks.

1 Like

You can try running a virtual framebuffer with xvfb. It won’t use your GPU, but it’s straightforward to add to a docker container. Please see this script that we use in our ign-rendering CI.

Hope this helps!

1 Like

If you also want to use your GPU for rendering (but still headless), you can use VirtualGL together with xvfb. We launch gazebo like this:

xvfb-run -a -s '-screen 0 2100x1400x24' vglrun +v -d /dev/dri/card1 ign gazebo

You’ll need to go through the setup of virtualgl for this to work (mainly setting correct permission for /dev/dri/cardX devices). And you will also need to make these devices accessible inside the container.

1 Like