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

**URL:** <https://forums.balena.io/t/docker-compose-start-a-subset-of-services-aka-service-profile/353515>\
**Category:** Product support\
**Tags:** docker-compose\
**Created:** [March 3, 2022, 8:47am UTC](https://forums.balena.io/t/docker-compose-start-a-subset-of-services-aka-service-profile/353515 "2022-03-03T08:47:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndMaz](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@AndMaz](https://forums.balena.io/u/AndMaz)\
**Post date:** [March 3, 2022, 8:47am UTC](https://forums.balena.io/t/docker-compose-start-a-subset-of-services-aka-service-profile/353515/1 "2022-03-03T08:47:06Z")

</div>

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: [https://docs.docker.com/compose/profiles/](https://docs.docker.com/compose/profiles/)

From the docs ([docker-compose.yml fields - Balena Documentation](https://www.balena.io/docs/reference/supervisor/docker-compose/)) 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:

> [@Selectively running containers on a device](https://forums.balena.io/t/selectively-running-containers-on-a-device/16086/22):
>
> Hi @craigson , the restart: no will not instantiate the container in “stopped”. That field just means the container won’t be restarted in the case that its PID 1 process exits. So it will always start. You can also probably use restart: on-failure which would only restart the container if your process exited for some failed reason, but if it was exit 0 then it would just stop.

> [@Selective Docker Compose](https://forums.balena.io/t/selective-docker-compose/37746):
>
> We’ve got a use case EXTREMELY similar to the following thread where we have one version of our application that runs an integrated app/api with an attached screen and then one that runs with only the api and communicates over TCP/IP. The difference here is that the integrated device with a screen is a Pi 3B+ and the standalone api is run on a Pi Zero W. They will share 2 of 3 services with the same exact code base. That means I’m forced to do two difference applications, which seems like the…

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [April 22, 2022, 12:04pm UTC](https://forums.balena.io/t/docker-compose-start-a-subset-of-services-aka-service-profile/353515/5 "2022-04-22T12:04:21Z")

</div>

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!
