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
sudo apt update && sudo apt upgrade -y2. Installing Docker
sudo apt-get install docker.io docker-compose3. Ensuring our setup is working perfectly
sudo service docker.io statusIt should output like this:
● 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 agoTriggeredBy: ● 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.sock4. 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
sudo docker-compose upThen to access the terminal
sudo docker exec -it ubuntu-ros-container /bin/bash5. Initializing
source /opt/ros/iron/setup.bashAlternatively you can add it to your .bashrc/.zshrc