A Docker setup for ROS2 Humble with NVIDIA GPU support, Gazebo, RViz2, and TurtleBot3. The goal is to get a working ROS2 environment running with minimal effort.
- ROS2 Humble Hawksbill
- NVIDIA GPU support via Container Toolkit
- Gazebo simulation
- RViz2
- TurtleBot3 (Burger)
- A basic publisher/subscriber package (
pubsub_pkg) to test things out - Mounted workspace so edits on your host show up in the container immediately
You need these installed on your machine before starting:
- Docker
- Docker Compose
- NVIDIA GPU drivers
- NVIDIA Container Toolkit
- Linux with a desktop (needed for Gazebo and RViz2)
When using this template on GitHub, just name your repo whatever makes sense for your project. After cloning, if you want to rename the container too, open docker-compose.yml and change the container_name and image name fields.
1. Use this template on GitHub
Click "Use this template" and create your own repo.
2. Clone it
git clone https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git
cd YOUR_REPO_NAME3. Allow GUI apps (do this after every login)
xhost +local:docker4. Build the image
docker compose build5. Start the container
docker compose up -d6. Enter the container
docker exec -it ros2_ws_container bashInside the container:
cd /ros2_ws
colcon build
source install/setup.bashTerminal 1:
ros2 run pubsub_pkg publisherTerminal 2:
docker exec -it ros2_ws_container bash
ros2 run pubsub_pkg subscriberGazebo:
docker exec -it ros2_ws_container bash
gazeboRViz2:
docker exec -it ros2_ws_container bash
rviz2TurtleBot3:
docker exec -it ros2_ws_container bash
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.pyStart:
docker compose up -dEnter:
docker exec -it ros2_ws_container bashStop:
docker compose downros2-humble-nvidia-docker-template/
├── docker-compose.yml
├── Dockerfile
├── ros2_ws/
│ └── src/
│ └── pubsub_pkg/
└── README.md
The ros2_ws folder is mounted, so any file you edit on your host is live inside the container without rebuilding.
Vignesh Suresh