Run ROS2 in a dockerised environment, which automatically detects the host hardware and selects the runtime accordingly.
System tested
- ✅ Ubuntu 22.04 (amd64/arm64)
- ✅ Ubuntu 24.04 (amd64)
- ✅ Fedora 42 (amd64)
Note: Only Nvidia GPU is supported currently.
Ensure that Docker & Nvidia Container toolkit is installed to use the GPU runtime of the container.
The target distro could be change via the ROS_ENV arguement inside ros_config file.
... # === Update config below === ROS_ENV="jazzy" ROS_TYPE="desktop" ...ROS_ENV: The ROS distro.ROS_TYPE: The type of ROS installation.coreconsists of the minimum packages to run ROS, whereasdesktop_fullincludes most of the core components, perception and simulation packages.
The workspace directory that is attached to the container is defined in the volumes section inside docker-compose.yml file, which is attached with the following structure: <host_dir>:<container_dir>.
... volumes: - ./beluga_ws:/home/user/beluga_ws ...Enter the docker container via the enter_env script.
cd ~/beluga sudo chmod +x enter_env.sh ./enter_env.shIf you are using Wayland and/or Fedora, please do not skip this section as RViz2 may crash upon launching the usual way.
To run RViz2 in docker, there are a few additional steps to be taken.
To start Rviz2, export QT_QPA_PLATFORM as xcb, since Rviz2 does not support Wayland.
QT_QPA_PLATFORM=xcb rviz2Similarly, export QT_QPA_PLATFORM as xcb before running gazebo. (Reference)
QT_QPA_PLATFORM=xcb gz sim