Skip to content

docs: Add guide for running ROS2 with Docker#24108

Open
shakirth-anisha wants to merge 3 commits intodocker:mainfrom
shakirth-anisha:ros2_guide
Open

docs: Add guide for running ROS2 with Docker#24108
shakirth-anisha wants to merge 3 commits intodocker:mainfrom
shakirth-anisha:ros2_guide

Conversation

@shakirth-anisha
Copy link

@shakirth-anisha shakirth-anisha commented Feb 10, 2026

Description

Adds a new guide for running and developing ROS 2 applications using Docker.
This guide walks users through containerizing ROS 2 workflows, setting up a development environment, and running ROS 2 nodes inside containers and a simple end-to-end example using turtlesim.

Related issues or tickets

Closes #24014

Reviews

New content added under content/guides/ros2
docker buildx bake validate executes with no errors or warnings
Follows existing Docker guide structure and front matter
No changes to existing guides

  • Technical review
  • Editorial review
  • Product review

@netlify
Copy link

netlify bot commented Feb 10, 2026

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 81bbf20
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/698dbe5f64b6ff0008bdbb5e
😎 Deploy Preview https://deploy-preview-24108--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dvdksn
Copy link
Contributor

dvdksn commented Feb 12, 2026

/review

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation Review Summary

Reviewed the new ROS 2 guide documentation. Found 2 issues that should be addressed:

  1. Missing newline at end of file in run-ros2.md (high severity)
  2. Incorrect coordinates in explanation in turtlesim-example.md (medium severity)

Please see inline comments for details.

Copy link
Contributor

@dvdksn dvdksn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @shakirth-anisha for writing this up. Really appreciate it.

I believe we can simplify things by leveraging Docker Compose directly instead of devcontainers. I opened a PR to your example repository that shows my thinking:

shakirth-anisha/docker-ros2-workspace#1

Comment on lines +95 to +98
```console
$ ros2 --version
$ which colcon
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```console
$ ros2 --version
$ which colcon
```
```console
$ echo $ROS_VERSION
$ which colcon
```

Before you begin, make sure you're familiar with the following:

- [Docker Desktop](https://docs.docker.com/desktop/): You must have Docker Desktop installed and running.
- [Homebrew](https://brew.sh/) (macOS users): If you are using macOS, you must have Homebrew installed to manage dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed! See below

Suggested change
- [Homebrew](https://brew.sh/) (macOS users): If you are using macOS, you must have Homebrew installed to manage dependencies.

Comment on lines +53 to +70
- `.devcontainer/` : Holds the configuration used by Visual Studio Code to open the workspace in a container.
- `Dockerfile` : Builds the ROS 2 development image. It uses an official ROS 2 base image, creates a non-root development user, and installs required system and ROS 2 dependencies.
- `devcontainer.json` : Defines how Visual Studio Code builds, runs, and connects to the container. It configures the workspace location, user context, mounted directories, environment variables, networking options, installed extensions, and post-create setup commands.

## Open and build dev container

1. Install the `devcontainer` CLI:

- Linux / Windows
```console
$ sudo apt update && sudo apt upgrade
$ sudo apt install -y nodejs npm
$ sudo npm install -g @devcontainers/cli
```
- macOS
```console
$ brew install devcontainer
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can avoid having to install node/devcontainers, or having homebrew as a prerequisite, by using Docker Compose.

2. Execute the following commands to build and start the container:

```console
$ devcontainer up --workspace-folder ws/src
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With compose:

$ cd <workspace>
$ docker compose up -d

3. Once the container is running, execute commands inside it using `exec`:

```console
devcontainer exec --workspace-folder ws/src /bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
devcontainer exec --workspace-folder ws/src /bin/bash
$ docker compose exec ros2 bash

Comment on lines +102 to +110
## Switch ROS 2 distributions

1. Create a new cache directory for the target distribution:

```console
$ mkdir -p ~/ws/cache/[ROS_DISTRIBUTION]/{build,install,log}
```

2. Update the cache paths in `src/.devcontainer/Dockerfile` and `src/.devcontainer/devcontainer.json`, changing from `humble` to `ROS_DISTRIBUTION`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed if we keep the cache directories as volumes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Building and running ROS 2 applications using Docker

2 participants