[docker-compose] start a subset of services, aka, service "profile"

Hi

Recent versions of docker-compose support “profile” attribute that allows to selectively start a subset of services declared in the docker-compose file.
More info here: Using profiles with Compose | Docker Documentation

From the docs (docker-compose.yml fields - Balena Documentation) it seems that balena does not support the “profile”.

My question is: From balena perspective, what’s the cleanest way of conditionally starting a subset of services declared in a docker-compose?

Scenario: Depending on the hardware attached to my RPi I want to start all or some of the services defined in the docker-compose

After some investigation I see that I’m not the only one who want this feature:

Hello @AndMaz first of all welcome to the balena community and apologizes to reply you so late!

You are right, other members from the community requested this feature lately as well. I want to thank you for collecting these forums messages. I added all of this information internally for this feature request.

First of all, we still do not support the profile attribute as it belongs to docker-compose v3. At the moment we support most of the v2.1-2.2 and working on the v2.4 currently. Internally some people see this interesting but sadly this is not implemented yet.

Some ideas or workarounds that you can use today are:

  • comment your services and push different releases (A / B) on balenaCloud and then pin the releases to the devices (tag the image to maintain the image data).
  • use an envvar and then exit services if the envvar is set to a specific value.

Let me know if that works!