# Restart container1 from container2 using supervisor-api

**URL:** <https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886>\
**Category:** Product support\
**Tags:** summary\
**Created:** [April 9, 2018, 1:25am UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886 "2018-04-09T01:25:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![donfmorrison](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/donfmorrison/32/743_2.png) [@donfmorrison](https://forums.balena.io/u/donfmorrison)\
**Post date:** [April 9, 2018, 1:25am UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/1 "2018-04-09T01:25:52Z")

</div>

In the new multicontainer architecture - totally awesome by the way! - is it possible to start, stop, or restart a service container from another container?

Say I have container1 and I want to restart container2 for some reason? Can I use the supervisor api to perform this action from within container1?

Don

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [April 10, 2018, 4:58pm UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/5 "2018-04-10T16:58:50Z")

</div>

Hi @donfmorrison!  
There are actually a few supervisor endpoints for that, but they aren’t documented yet, and they reference services by an `imageId` that is not available to the containers anyways, so you currently wouldn’t be able to use them.

We’re still working on completing the “v2” supervisor API so we’ll keep this use case in mind. Would you mind telling us a bit more about your use case to understand how/why you want to do this?

---

<div class="post-metadata">

**Author:** ![donfmorrison](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/donfmorrison/32/743_2.png) [@donfmorrison](https://forums.balena.io/u/donfmorrison)\
**Post date:** [April 11, 2018, 6:30pm UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/7 "2018-04-11T18:30:40Z")

</div>

@pcarranzav let’s say I have 3 microservices running:

- ui
- api
- some\_continuous\_worker

I need to make a configuration change to the worker process and my thought was that I would update the config for that “worker” – stored outside the worker container, maybe in a db or config file – and I was thinking I needed a way to trigger that “worker” to use the new config. My thought was it would be easy to just restart that microservice. The api service will actually update the config, and then I was thinking it could restart the worker container using the supervisor device api.

It’s likely not a “good” design but it seemed better than exposing an api layer on the “worker” just for this purpose. I should probably just detect this change from the worker instead and have it react accordingly. Thanks for making me think through this.

Although, I still think this “restart a particular microservice container from another container” could be useful!

Don

---

<div class="post-metadata">

**Author:** ![zagatta-sonah](https://avatars.discourse-cdn.com/v4/letter/z/e47c2d/32.png) [@zagatta-sonah](https://forums.balena.io/u/zagatta-sonah)\
**Post date:** [April 19, 2018, 8:39am UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/8 "2018-04-19T08:39:48Z")

</div>

We have a similar set-up and would need the same functionality (maybe even a little bit extended) to restart containers.

Set-Up:

- config\_saver
- service1
- service2

We also **safe configs** (basically the same as loading them from a db, in our case they are saved to a shared volume) and we want to **restart** service1 and send a message to service2 to **reload** the configs (it should not be restartet)

We would love to see the documentation soon on what you @pcarranzav implemented already and want to support @donfmorrison 's need for

> restart a particular microservice container from another container

functionality.

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [April 20, 2018, 5:35pm UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/10 "2018-04-20T17:35:22Z")

</div>

Regarding signaling to the service to reload a config - you could you expose a small API on that container, that upon a correct request would handle it as you’d like it (e.g. reloading a config). That would probably the most versatile one, since while `restart` a service is pretty universal, other behaviours like `reload` depends on the software running in that service, and needs to be handled appropriately - and your application is in the best place to handle it, IMHO.

---

<div class="post-metadata">

**Author:** ![zagatta-sonah](https://avatars.discourse-cdn.com/v4/letter/z/e47c2d/32.png) [@zagatta-sonah](https://forums.balena.io/u/zagatta-sonah)\
**Post date:** [April 20, 2018, 5:56pm UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/11 "2018-04-20T17:56:15Z")

</div>

> > and your application is in the best place to handle it

I guess i will handle the reload functionality internally  
but I am looking forward to the `restart` functionality

---

<div class="post-metadata">

**Author:** ![zagatta-sonah](https://avatars.discourse-cdn.com/v4/letter/z/e47c2d/32.png) [@zagatta-sonah](https://forums.balena.io/u/zagatta-sonah)\
**Post date:** [May 10, 2018, 10:03am UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/12 "2018-05-10T10:03:12Z")

</div>

@imrehg is there any news on this functionality?

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [May 10, 2018, 10:15am UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/16 "2018-05-10T10:15:11Z")

</div>

Hi, it is worked on, the issue open for the supervisor is at here:

> <https://github.com/balena-io/balena-supervisor/issues/640>

(You can subscribe to this issue to get any notifications on the progress).

---

<div class="post-metadata">

**Author:** ![jason10](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/jason10/32/1464_2.png) [@jason10](https://forums.balena.io/u/jason10)\
**Post date:** [April 30, 2019, 10:20pm UTC](https://forums.balena.io/t/restart-container1-from-container2-using-supervisor-api/2886/23 "2019-04-30T22:20:46Z")

</div>

You can also use a health check to restart a container using some combination of:

- health check checks to see if configuration has changed or is younger than startup of container
- health check checks to see if “restart flle” has been written to shared volume
