How to trigger start/stop of container from within another container?

Say you have an app with a function that needs to run another app - but rarely so it should be shut down most of the time. The first app is running in a docker container and needs some functionality to launch the other app, which runs in another contianer. I would figure there is a standard way of doing this by now. I’d prefer not to do docker-in-docker, though in one case that could work.

In another case, an app running in a docker container needs to trigger a rebuild of that container itself. Which means the host needs to run docker-compose build that-container.

What is the ideal way to do this?
Thank you everyone :slight_smile:

It may be late, but you can mount the docker socket like:

-v /var/run/docker.sock:/var/run/docker.sock 

and use an any client that can use the socket. It can be the docker cli or an SDK