Balena multiple services and docker "layer deduplication"?

Hi there @luchko. By the nature of docker, when pulling images, assuming you are not squashing the images, the engine will pull the shared layers once, and only pull the different layers when they exist. For instance if you have 3 different services building from a node parent image, all these services will share the node layers and the extra data downloaded will be the distinct files in these services.

In the example you provided you are correct that since there is only one image, the engine will only pull the ros:noetic-ros-core-focal image once and just configure the services with the distinct commands.

You can also achieve the same when building from a local dockerfile by using the build and image properties together. For instance

service1:
   build: ./my-service
   image: my-service
   command: ./my-command hello
service2:
   build: ./my-service
   image: my-service
   command: ./my-command goodbye

In this case both services will share the same image which means that data will only be downloaded once.

Please let us know if this answers your question or if you need some more specific examples.