Skip to content

Getting started with ROS 2 Iron Irwini on Docker

This page will help you understand how to operate ROS 2 without any worries about Ubuntu 18.04/20.04’s compatibility.

Disclaimer

This project uses ROS 2 and not ROS 1. I use Iron for the demo and Ubuntu 22.04 Jammy inside the container.

Installing ROS 2

Steps

1. Updating your package index

Terminal window
sudo apt update && sudo apt upgrade -y

2. Installing Docker

Terminal window
sudo apt-get install docker.io docker-compose

3. Ensuring our setup is working perfectly

Terminal window
sudo service docker.io status

It should output like this:

Terminal window
docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2024-02-27 16:29:42 IST; 48s ago
TriggeredBy: docker.socket
Docs: https://docs.docker.com
Main PID: 3019 (dockerd)
Tasks: 11
Memory: 30.9M
CGroup: /system.slice/docker.service
└─3019 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
4. Running the container
Please create the following file with the name docker-compose.yaml
version: "3.3"
services:
ubuntu-ros:
container_name: "ubuntu-ros-container"
image: "sentinelag/ros2:latest"
tty: true
volumes:
- container_home:/home
volumes:
container_home:

Then, run

Terminal window
sudo docker-compose up

Then to access the terminal

Terminal window
sudo docker exec -it ubuntu-ros-container /bin/bash

5. Initializing

Terminal window
source /opt/ros/iron/setup.bash

Alternatively you can add it to your .bashrc/.zshrc