Use this Docker template for a quick setup of the ROS2 Humble environment.
-
docker/:
- Dockerfile: Defines the Docker image using ROS2 Humble, with user
ros2_user
and workspace~/ros2_ws
. - build_image.sh: Builds the Docker image as
ros2_image
. - run_container.sh: Initiates a container named
ros2_container
from theros2_image
. - shell_container.sh: Opens a shell in the
ros2_container
, ideal for multiple terminal sessions.
- Dockerfile: Defines the Docker image using ROS2 Humble, with user
-
ros2_ws/: The ROS2 workspace. Any files added here are automatically synchronized with the Docker container. Add ROS2 packages here for Docker container access.
- Build the Image: Go to
docker
and run:./build_image.sh
- Start the Container: From
docker
, execute:./run_container.sh
- Additional Shell (Optional): For a new shell inside the running container, use:
./shell_container.sh
- Launch a Docker container with:
./run_container.sh
- Inside the container, initiate the ROS2 publisher:
ros2 run demo_nodes_cpp talker
- In a new terminal, access the container:
./shell_container.sh ros2 run demo_nodes_cpp listener
Ensure your user has appropriate permissions by adding it to the Docker group:
sudo usermod -aG docker $USER
After executing the above command, you might need to log out and log back in for the group changes to take effect.