Start container only on demand

I am setting up an application for network management which is to be deployed in many different situations. In the different containers I have the management tools for different devices.

Is there any way to make Balena only start one container when the device is powered and then let this container decide which other containers to start?

I know you can start and stop containers from the API, but is it possible to disable “autostart” of the containers on boot?

Thanks,

Thomas

I don’t know exactly what software you are running on devices, but may I suggest an alternative? Let all containers run with application that listens for the request from other container (maybe http server or something else), when it gets a request it will exec program that you need to run on demand.

Another usecase would be a VPN client container that does not need to start automatically on startup but only when we trigger it via the Balena API (or web interface). Is this possible?

Hi @reinzor,
I’m afraid that there isn’t an option currently in the docker-compose to mark containers that shouldn’t be started.
A way to achieve something like this could be to

  • have those containers check on their startup script for a specific application or device tag using the balena API and exit if that’s not set or doesn’t have the excepted value.
  • have an “orchestrator” container that also checks for such application or device tags periodically and starts or stops the appropriate containers accordingly.

If you choose to use device tags, then you can use the supervisor API as well for this. Let me point you to the respective documentation page:
https://www.balena.io/docs/reference/supervisor/supervisor-api/#device-tags

Would something like this work for your use case?

Kind regards,
Thodoris

Thanks for your reply, seems we have to work around this then using another container starting and stopping the desired temporary container.