`Binding to a local port failed` while running containerized Gazebo setup on MacOS host

So I have an intel-based macbook with MacOS Sequoia. I have installed gazebo jetty binaries and it works with no issues.

However, for some other projects I need to run a containerized ubuntu setup with ROS 2 Jazzy + Gazebo Jetty. For the GUI, what am I trying to do is:

  1. Run gz sim in server mode inside the container
  2. Run gz sim GUI locally on the host mac machine

Theoretically I believe this should work and have successfully used this setup on a Ubuntu host machine earlier but I cannot get it to work on the Mac. Both the server and the gui start up successfully but are not able to communicate with each other. For my setup:

  • I am using Docker Desktop with a custom dockerfile which installs ROS 2 Jazzy and Gazebo jetty on an Ubuntu 24.04 base
  • I set the same GZ_PARTITION in both: the container with the server and host terminal with the GUI
  • I run the container with the --network=host option inside docker desktop

From what I understand, docker running inside a VM on the Mac might be creating some complications with this setup. At the same time, I believe this is something very primitive and I am probably missing some gz-transport env settings.

So basically my question is: How do I get this to work? What am I missing? I would love to get some more insights!

Update: I have enabled the Network Hosting option in Docker Desktop’s Settings > Resources > Network. After this when I execute the same setup, this is what I get in the terminal running the GUI:

Binding to a local port failed.
Binding to a local port failed.
Exception sending a multicast message:Can’t assign requested address

It’d be easier to debug this with just gz topic instead of the whole of Gazebo. I noticed you said you are running ROS 2 Jazzy and Gazebo Jetty. These are not supported combinations. Are you building from source? Is the GUI working within the VM? Can you try using the version of Gazebo that comes with Jazzy via ros-jazzy-ros-gz (see ROS 2 Gazebo vendor packages)?

If you are sure none of those are issues, here are some other things I’d try:

  1. Check that the versions on both sides are the same gz topic --versions
  2. Set GZ_VERBOSE=1 on both sides and run gz topic -t /chatter -m gz.msgs.StringMsg -p 'data:"Hello, world"' inside docker and gz topic -e -t /chatter in the host
  3. Try using a relay Gazebo Transport: Relay

Didn’t realise I was using incompatible versions of the ROS 2 and Gazebo. I have fixed that with the suggested package (ros-jazzy-ros-gz). I also installed the gz-harmonic binaries on my host Mac machine to match the versions. However, the issue still persists:

  1. The gz topic –-versions on both sides are the same: 15.0.0
  2. Using the publisher and subscriber as suggested did not work.
  3. I followed the Relay tutorial but the result is same. I am not able to see any published topics being printed over at the subscriber’s terminal.

Here is a screenshot of the publisher inside the container with GZ_VERBOSE=1:

Here is a screenshot of the Subscriber on the host machine with GZ_VERBOSE=1: