Stowaway: put Docker containers to sleep when idle, wake them on demand, and control them from Home Assistant

Hi everyone,

I built a small tool for my home server called Stowaway, along with a Home Assistant integration for it, and I’d love some feedback.

What Stowaway does

Stowaway sits between your dashboard or bookmarks and your containers’ web interfaces. When you open an app’s link, it starts the container, shows a short “waking up” page, and then lets you through. When nobody has used the app for a while, it stops the container again. Apps you only open now and then (Tdarr, Calibre-Web, a game server, that thing you installed to try out) stop using RAM and CPU around the clock.

It’s careful about when to put something to sleep. It won’t stop an app that’s busy, for example during a transcode or download, and helper containers like Tdarr nodes wake and sleep together with their main app.

What the integration gives you

For each app Stowaway manages, you get:

Entity What it does
switch.<app>_awake Wake the app, or put it to sleep now
switch.<app>_don_t_wake Block waking. Visitors see a “switched off” page instead
sensor.<app>_status Awake, Asleep, Starting, Updating, Maintenance… Attributes include CPU and memory
sensor.<app>_sleeps_at When an idle app will go to sleep
sensor.<app>_next_restart The next scheduled restart
binary_sensor.<app>_update_ready A newer image is ready to install
button.<app>_keep_awake_1_hour / _restart_now One-tap buttons to keep the app awake or restart it

There are also three actions: stowaway.keep_awake (for a set number of minutes, or forever), stowaway.release and stowaway.sleep (with an optional block). Stowaway itself gets sensors for how many apps are asleep and how much memory that frees.

You can also set an app to “Only when I say so”. Stowaway then never puts it to sleep on a timer, and Home Assistant decides when it runs.

Example: switch media servers off while nobody’s home

yaml

automation:
  - alias: Media servers off while away
    triggers:
      - trigger: numeric_state
        entity_id: zone.home
        below: 1
        for: "00:15:00"
    actions:
      - action: stowaway.sleep
        target:
          entity_id: [switch.plex_awake, switch.jellyfin_awake]
        data:
          block: true   # leave this out if remote streaming should still be able to wake them

  - alias: Media servers back when home
    triggers:
      - trigger: numeric_state
        entity_id: zone.home
        above: 0
    actions:
      - action: switch.turn_off
        target:
          entity_id: [switch.plex_don_t_wake, switch.jellyfin_don_t_wake]

Example: keep Jellyfin awake for movie night

yaml

- action: stowaway.keep_awake
  target:
    entity_id: switch.jellyfin_awake
  data:
    minutes: 240

Installing

  1. Run Stowaway on your Docker host. There’s a sample compose file in the repo, and it works on OMV, Unraid, TrueNAS, Synology and plain Docker.
  2. In HACS, go to ⋮ → Custom repositories and add https://github.com/Sat32blk/stowaway-homeassistant as an Integration. Install it, then restart Home Assistant.
    Open in HACS
  3. In the Stowaway dashboard, go to Integrations → Home Assistant → Create token.
  4. In Home Assistant, go to Settings → Devices & services → Add integration → Stowaway, and enter Stowaway’s address and the token.

Links

Both are free and MIT licensed. Bug reports, ideas and automation examples are welcome, here or on GitHub. I’d especially like to hear what automations people come up with.

What’s new in Stowaway itself (1.6.x)

If you haven’t seen Stowaway: it sits in front of your containers’ web pages. When you open an app’s link and the app is asleep, Stowaway starts it, shows a short “starting…” page, then sends you straight in. When nobody has used it for a while, Stowaway stops it again. It also works with TV apps, API clients and live connections, and it never puts an app to sleep while it’s busy (a transcode, a download).

One list for your whole server
The dashboard lists every container in one place. Each app’s panel shows:

  • Sleep: how it’s put to sleep: after a set idle time, only when told (e.g. by Home Assistant), or with awake hours such as 8 am to 6 pm weekdays
  • Updates: whether a newer image is waiting, and whether it installs automatically
  • Usage: live CPU and memory
  • Last opened by: which device opened it (e.g. livingroom-tv, Chrome on Android), or whether Home Assistant or a schedule woke it

At the top it shows how much memory and CPU sleeping apps are freeing right now, and how much CPU time they’ve saved this week. Click Let Stowaway manage on any container to start putting it to sleep.

Settings per app, in tabs

  • Sleep timer
  • Staying awake (while busy, set awake hours, or a keep-awake timer)
  • Address and opening
  • Companions
  • Updates and restarts
  • Dashboards
  • Home Assistant

Companion containers: helpers like Tdarr’s nodes, or an app’s database, wake and sleep with their main app and keep it awake while they’re working.

Updates and scheduled restarts

  • Stowaway checks every container for a newer image, including ones it doesn’t put to sleep.
  • Install with Update now, or let it update automatically the next time the app wakes or at a scheduled restart.
  • If a new version won’t start, it goes back to the previous one by itself.
  • Restart (and optionally update) any container daily, weekly or monthly at a set time.

These show up in Home Assistant too, through binary_sensor.<app>_update_ready.

Dashboards set up for you, and kept up to date
In an app’s Dashboards tab, one click adds it to:

  • Homarr: through Homarr’s API
  • Heimdall: a tile with the app’s own icon, in the category you pick
  • Homepage and Glance: written into their config files

From then on the dashboard shows each app’s live status: In Use, Sleeping in 8 min, Idle or Sleeping, plus Waking up, Updating and so on. Checking the status never wakes the app. After a Stowaway update, the same button brings the dashboard’s setup up to date. Dashboards on macvlan work too, and Dashy and others can use the status address.

A tile for Stowaway itself
It shows how many apps are awake and asleep, and how much memory and CPU sleeping them frees, on Homarr, Heimdall, Homepage or Glance. You pick which numbers it shows, and Homarr, Heimdall and Glance follow your choices automatically.

Fits your setup

  • macvlan and ipvlan containers
  • HTTPS with Let’s Encrypt (DuckDNS, Cloudflare or plain HTTP checks)
  • a sign-in for the dashboard
  • runs on amd64 and arm64

Stowaway itself uses about 40 MB of memory and almost no CPU.