ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Can colcon be used in a multi-stage Docker build to minimize the container size of ROS 2 images?

Yes colcon can be used in multi-stage builds and it is expected (though I dont have numbers to compare) to yield you smaller images. Here you can find an example of a multi-stage build with colcon. An interesting work in progress is the ability to tell rosdep to install only specific dependency types (e.g. only runtime dependencies for your final image)

Is it possible to create even smaller container sizes, though, than ros-core or ros-base

This is something that would be great as when installing "metapackages" you always end up with some things you don't need. There has been a dicussion to provide a C++ only set of packages to be able to run a simple talker listener. This should yield much smaller images.

Or is ros-core already the bare minimum of what is needed?

Some work has been done recently to trim a bit the size of the ros_core images (ROS 1 or ROS2) https://github.com/osrf/docker_images/pull/357 and https://discourse.ros.org/t/generating-dev-and-runtime-artefacts-from-ros-packages/12448. That last discourse post emphasize the need for packages to declare as runtime dependencies only what they really need at runtime.

As far as ROS 2 images are concerned I believe there is still much size to be gained. One reason is that message packages debs are big in ROS 2 because they come with headers and libraries for each DDS implementation. By building these packages yourself with support for only 1 implementation you can reduce size significantly.