# Download updates, reboot, boot into the updated container

**URL:** <https://forums.balena.io/t/download-updates-reboot-boot-into-the-updated-container/369244>\
**Category:** Product support\
**Created:** [October 30, 2023, 4:15pm UTC](https://forums.balena.io/t/download-updates-reboot-boot-into-the-updated-container/369244 "2023-10-30T16:15:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bal](https://avatars.discourse-cdn.com/v4/letter/b/91b2a8/32.png) [@bal](https://forums.balena.io/u/bal)\
**Post date:** [October 30, 2023, 4:15pm UTC](https://forums.balena.io/t/download-updates-reboot-boot-into-the-updated-container/369244/1 "2023-10-30T16:15:31Z")

</div>

Hi.

We have implemented the [“Update when user interacts”](https://forums.balena.io/t/update-when-user-interacts/4590) strategy.

Let me summarize the process (Assume there’s a new release available):

1. User initiates update by pressing a button on their device
2. Create a lock file
3. Pin the device to the new release
4. Trigger update download using the endpoint: `/v1/update`
5. Show “Downloading update…” message to user
6. After download finishes, show “Reboot” button to user
7. User pressed “Reboot” button
8. Trigger device reboot using the endpoint: `/v1/reboot` with `{'force': true}`
9. Device boots back, old containers are started (Old UI shows)
10. Supervisor kills/deletes the old containers and applies updates
11. New containers are started

The step we’re having problem is step 9. When device boots back the old containers are started and shows our old UI for a few seconds until after supervisor finishes applying the update.

Is there a way we can make it so the old containers are not started?  
So we’d have a following for step 9:

- 
  1. Device boots back, old containers are not started (Blank screen)

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [November 2, 2023, 12:01pm UTC](https://forums.balena.io/t/download-updates-reboot-boot-into-the-updated-container/369244/4 "2023-11-02T12:01:41Z")

</div>

Hi there,

May I ask, what is the purpose of step 8? Is it to remove the lockfile?

---

<div class="post-metadata">

**Author:** ![bal](https://avatars.discourse-cdn.com/v4/letter/b/91b2a8/32.png) [@bal](https://forums.balena.io/u/bal)\
**Post date:** [November 2, 2023, 2:04pm UTC](https://forums.balena.io/t/download-updates-reboot-boot-into-the-updated-container/369244/6 "2023-11-02T14:04:39Z")

</div>

Step 8 is the “onclick” action for Step 7.  
We call `/v1/reboot` with `{'force': true}` to force a reboot. Device won’t reboot without `{'force': true}` flag since we still have the lockfile present.

We’re not removing the lockfile because it is removed automatically on reboot by the supervisor anyway.

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [November 3, 2023, 2:15pm UTC](https://forums.balena.io/t/download-updates-reboot-boot-into-the-updated-container/369244/8 "2023-11-03T14:15:33Z")

</div>

Hi there, I was just asking as if the reboot wasn’t strictly necessary, you could disable the lockfile without rebooting, and the device would update to the new container and UI - this might provide a smoother experience

If the exact steps you detailed are all strictly required, then I don’t think there is a way to force the device to not start the old containers as it boots. As it seems like the main issue is the old UI is being displayed pot update, maybe you could disable the screen using an env var you set during step 7 and then remove when the running release matches the target one?

---

<div class="post-metadata">

**Author:** ![bal](https://avatars.discourse-cdn.com/v4/letter/b/91b2a8/32.png) [@bal](https://forums.balena.io/u/bal)\
**Post date:** [November 3, 2023, 2:57pm UTC](https://forums.balena.io/t/download-updates-reboot-boot-into-the-updated-container/369244/9 "2023-11-03T14:57:05Z")

</div>

Thanks.

I ended up using this following solution. It works well.

On boot, from my old container poll `/v2/state/status` to detect if an update is being applied (`appState == "applying"`) and show “Updating please wait…” UI. Then continue rendering regular UI when update finishes.

---

<div class="post-metadata">

**Author:** ![rcooke-warwick](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@rcooke-warwick](https://forums.balena.io/u/rcooke-warwick)\
**Post date:** [November 3, 2023, 3:33pm UTC](https://forums.balena.io/t/download-updates-reboot-boot-into-the-updated-container/369244/10 "2023-11-03T15:33:18Z")

</div>

Nice work! Thank you for sharing, hopefully this forum thread will be of future use to anyone looking to achieve a similar effect 🙂
