This repository provides a minimal example for running ROS 2 Humble in Docker.
It includes a simple Python package located in the src/hello_py
directory.
- Docker (tested with Docker 20.10 or later)
- git
- Install Docker following the official instructions.
- Clone this repository:
git clone <repo-url> cd docker4ros2
- Start the development container:
./run_docker.sh
- Inside the container build the workspace and source the setup files:
source /opt/ros/humble/setup.bash colcon build --symlink-install source install/setup.bash
- Run the example node:
ros2 run hello_py hello
- The
src/hello_py
package is a simple example that printsHello, ROS2!
every second. - If you wish to create additional packages, add them inside the
src
directory and rebuild withcolcon build
. - ROS 2 Humble packages are only provided for Ubuntu 22.04 (Jammy). If you are on
Ubuntu 24.04 or another release,
apt-get install ros-humble-*
will fail. In that case use the Docker instructions above or install ROS 2 from source on a supported distribution.
If you prefer docker compose
, a preconfigured setup is provided in
.devcontainer/docker-compose.yml
:
docker compose -f .devcontainer/docker-compose.yml build
docker compose -f .devcontainer/docker-compose.yml run ros2-dev
This launches the same development environment as run_docker.sh
and mounts
the repository in /home/ros/ros2_ws
inside the container.