docs: Add guide for running ROS2 with Docker#24108
docs: Add guide for running ROS2 with Docker#24108shakirth-anisha wants to merge 3 commits intodocker:mainfrom
Conversation
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
/review |
There was a problem hiding this comment.
Documentation Review Summary
Reviewed the new ROS 2 guide documentation. Found 2 issues that should be addressed:
- Missing newline at end of file in
run-ros2.md(high severity) - Incorrect coordinates in explanation in
turtlesim-example.md(medium severity)
Please see inline comments for details.
dvdksn
left a comment
There was a problem hiding this comment.
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:
| ```console | ||
| $ ros2 --version | ||
| $ which colcon | ||
| ``` |
There was a problem hiding this comment.
| ```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. |
There was a problem hiding this comment.
Not needed! See below
| - [Homebrew](https://brew.sh/) (macOS users): If you are using macOS, you must have Homebrew installed to manage dependencies. |
| - `.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 | ||
| ``` |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
| devcontainer exec --workspace-folder ws/src /bin/bash | |
| $ docker compose exec ros2 bash |
| ## 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`. |
There was a problem hiding this comment.
This is not needed if we keep the cache directories as volumes
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/ros2docker buildx bake validateexecutes with no errors or warningsFollows existing Docker guide structure and front matter
No changes to existing guides