Minimal Docker setup for running ROS 2 on Apple Silicon devices with visualization and multiple machines discovery support.
- ROS2 discovery across multiple machines
- Visualization support with Foxglove
-
Clone this repository:
$ git clone https://github.com/mlsdpk/ros2-docker-setup.git $ cd ros2-docker-setup -
Update the
.envfile with your configuration:ROS_DISTRO=jazzy ROS_DOMAIN_ID=0 RMW_IMPLEMENTATION=rmw_cyclonedds_cpp HOST_IP=0.0.0.0 UDP_PORT_RANGE=7400-7500 USER_PROVIDED_DIR=/path/to/your/directory CYCLONEDDS_URI_FILE=cyclonedds.xml FOXGLOVE_PORT=8765
Note on multiple machines setup:
HOST_IPmust be your actual local network IP address (e.g., 192.168.x.xxx) for inter-machine communication. On macOS,network=hostmode is not supported, so here we will explicitly map ROS 2 UDP ports. The default port range (7400-7500) supports typical setups with ROS_DOMAIN_ID=0. But, if you need to use more domain IDs or participants, extend this range accordingly. See more details on this here.
-
Build the Docker container:
docker compose build
Start the container in the background:
docker compose up -dTo connect to the running container:
docker exec -it <container-name> /bin/bashYou can find the container name by running:
docker ps
This setup supports visualization via Foxglove Studio using a WebSocket connection. By default, the WebSocket server runs on TCP port 8765.
You can customize the port by modifying the FOXGLOVE_PORT variable in your .env file.
Inside the container, start the foxglove_bridge with:
ros2 launch foxglove_bridge foxglove_bridge_launch.xmlYou can now open Foxglove Studio and connect to the WebSocket to visualize our ROS2 data. For more information, see here.