0% found this document useful (0 votes)
38 views3 pages

Getting Started with ROS and Docker

This tutorial provides instructions for installing Docker and using it to run ROS containers on your local machine. It explains how to pull ROS images from Docker Hub, run ROS containers interactively, stop containers, and links to a video demonstration. The tutorial is aimed at beginners and allows using ROS without installing it locally by running ROS versions in isolated Docker containers.

Uploaded by

ahasimplemail
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

Getting Started with ROS and Docker

This tutorial provides instructions for installing Docker and using it to run ROS containers on your local machine. It explains how to pull ROS images from Docker Hub, run ROS containers interactively, stop containers, and links to a video demonstration. The tutorial is aimed at beginners and allows using ROS without installing it locally by running ROS versions in isolated Docker containers.

Uploaded by

ahasimplemail
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

docker/Tutorials/Docker - ROS Wiki [Link]

org/docker/Tutorials/Docker

Please ask about problems and questions regarding this tutorial on [Link]
([Link] Don't forget to include in your question the link to this page, the versions of your
OS & ROS, and also add appropriate tags.

Getting started with ROS and Docker


Description: This tutorial walks you through installing Docker and spinning up your first ROS container on
your computer.

Keywords: ROS, Docker

Tutorial Level: BEGINNER

For reasons you'll come to understand in a bit, a host installation of ROS is not required for most of these
tutorials unless otherwise specified. To quickly grasp how this is possible with Docker, it's recommended
you try it ([Link] out with the online tutorial.

Contents
1. Installing Docker
2. Using ROS images
1. Pulling ROS images
2. Running ROS containers
3. Stopping ROS containers
4. Video Demonstration

Installing Docker
Before starting this tutorial please complete installation as described in Docker's installation instructions
([Link] Installation instructions are available for multiple operation systems
including Ubuntu, Mac OS x, Debian, Fedora and even Microsoft Windows. ¯\_(ツ)_/¯

Note that for recent Linux distros, the installation really just boils down to running a single wget command.
You may also want add your user to the docker group to avoid having to use sudo permissions when you
use the docker command, as also noted further into Docker's installation instructions.

Using ROS images


1. Pulling ROS images
Now that you have Docker installed, lets pull down a ROS container image:

1 of 3 10/4/23, 09:13
docker/Tutorials/Docker - ROS Wiki [Link]

docker pull ros

This will pull the latest tagged LTS image of ROS from Docker Hub ([Link]
/signup/) onto your local host machine. Specifically, the image name "ros" is registered with Docker's
Official ROS Repo images ([Link]

Take a look at the Official ROS Repo and you'll find additional tag names you can use to help specify what
exact version and/or meta package level you'd like to use. The tags are built from each other in the same
manner as the respective ROS metapackage ([Link] dependencies
interlink, i.e. if you were to pull:

docker pull ros:noetic-robot

You would then also then locally posses the "noetic-ros-core" and "noetic-ros-base" tagged images as well.

2. Running ROS containers


Now that you have the ROS image downloaded, you can spin up a container from it by calling:

docker run -it ros

This will move you into an interactive session with the running container. From here, it's basically as if
you're in a new bash terminal separate from your host machine. Now run the roscore command and you will
see ros master startup.

In a new terminal on the host machine, find the name of your new container, last container started using:

$ docker ps -l

Using the name of the container as the ID, in writing this tutorial docker happened to assign the string
"nostalgic_morse", we can start additional bash session in the same container by running:

docker exec -it nostalgic_morse bash

Once inside, we'll need to setup our environment. The best way to do this is to using the entrypoint script
included in the docker image:

source ros_entrypoint.sh

If you ran the docker pull ros command, you will have a ROS 2 installation (dashing, foxy, etc.) try:

ros2 topic list

If you pulled a ROS1 Docker container tag (noetic, kinetic, etc.) try:

roscore

2 of 3 10/4/23, 09:13
docker/Tutorials/Docker - ROS Wiki [Link]

3. Stopping ROS containers


To stop containers, we merely need to stop the original processes run by docker run command. We can
switch back to the terminal where roscore is running and hit ctrl-c to stop the ROS process, and then
exit to terminate the bash shell. You can also use the docker CLI to tell the docker daemon to stop or
remove the running container directly. Check the stop ([Link]
/commandline/stop/) and rm ([Link] docs here for
details.

4. Video Demonstration
Below video makes you understand how Docker can be utilized for different ROS versions on different
Operating systems.

ROS2 Docker GUI for Windows and Linux

Except where otherwise


noted, the ROS wiki is Wiki: docker/Tutorials/Docker (last edited 2022-11-04 06:24:40 by Muhammad Luqman (/Muhammad%20Luqman))

licensed under the


Creative Commons Attribution 3.0 ([Link]

([Link]

3 of 3 10/4/23, 09:13

Common questions

Powered by AI

To start an interactive ROS session within a Docker container, the command `docker run -it ros` is used, which creates an interactive terminal session in a new container based on the specified ROS image . Inside the session, running the `roscore` command initializes the ROS master node, making it possible to execute ROS functionalities. For managing container-based processes, a user can open a new terminal to interact concurrently or find container names using `docker ps -l`, allowing them to start additional bash sessions with `docker exec`. This flexibility in process management within Docker containers facilitates advanced ROS operations and development .

To stop running ROS containers in Docker without risking data loss or corruption, one should first stop any ROS processes running inside the container using commands like `ctrl-c` to gracefully terminate applications such as `roscore` . After this, the user should exit the bash shell session, ensuring all processes have finished cleanly . Alternatively, the Docker CLI can be utilized to stop or remove containers directly using commands like `docker stop` followed by the container name or ID, ensuring a proper shutdown sequence .

To pull specific versions of ROS images using Docker, one must use the appropriate tags associated with the desired ROS version. For example, running the command `docker pull ros:noetic-robot` will download the 'noetic-robot' image, which will also include 'noetic-ros-core' and 'noetic-ros-base' tagged images, due to the metapackage hierarchy . Tags play a significant role as they denote the specific versions and configurations of ROS, allowing users to select the exact setup needed for their application. This guarantees consistency and reliability across different environments .

Using Docker to run ROS applications has several advantages over installing ROS directly on a host system. First, Docker containers provide a controlled and isolated environment, minimizing the risk of conflicts with other software and dependencies. This isolation ensures consistent behavior across different environments, which is particularly useful for development and deployment . Moreover, since Docker containers encapsulate all necessary dependencies, developers can easily share their ROS environments with others, leading to increased collaboration and scalability. Finally, Docker allows easy management of different ROS versions and configurations, making it simpler to switch between different setups without altering the host system .

Adding a user to the Docker group during installation is recommended to avoid the necessity of using 'sudo' for Docker commands, which enhances usability and streamlines operations . This recommendation addresses potential security and convenience issues because using 'sudo' can pose security risks by requiring elevated permissions for every command, thus potentially exposing the system to vulnerabilities. By adding users to the Docker group, it simplifies command execution, reducing the need for excessive administrative access .

The ROS entrypoint script in Docker is crucial for setting up the environment inside a Docker container. After starting a bash session in a ROS Docker container using a command like `docker exec`, the script 'ros_entrypoint.sh' should be sourced to set up the necessary environment variables and configurations for ROS operations . This step is essential as it initializes the ROS environment, allowing commands like 'roscore' or 'ros2' to function correctly within the container. Hence, using the entrypoint script ensures that all dependencies and settings are correctly loaded to emulate a typical ROS setup .

You might also like