How to filter which services run on each device?

pendinguserresponse
status
#1

I have 3 devices, all run some of the services, but some don’t. How can ensure each device knows which services it should run?

Ideally, docker-compose.yaml would allow for a required_tags so I could tag the devices with their roles.

#3

One strategy could be to use a single service to bootstrap the services on your device. The “bootstrap” service could decide which services to start based on device variables.

#4

Hm, maybe that would work. Do you have any tips on how:

  • I can disable services, so they don’t automatically start, but instead get manually started by the bootstrap
  • How can I manually start services from this bootstrap service?
#9

Hi @fabiopedrosa , we don’t have a built in way to do that currently, but you can use ENV vars and a well designed entrypoint for you services as shown in this project here: https://github.com/tdicola/balena_logging_sensors_pt_3/blob/master/index.md . In that project you will see we use RUN_ON_DEVICES=collector-pi3 on a service to make it run on specific devices that have that env var set. The entrypoint script also has some more info on this here: https://github.com/tdicola/balena_logging_sensors_pt_3/blob/master/app/influxdb/balena_entrypoint.sh