Files
scripts/docker-stacks-update
jeremy e54d77893a docker-stacks-update: fix --list freeze + unbound variable
- Add missing 'shift' in --list case (caused infinite loop)
- Initialize color vars to empty strings before tput block
  (set -u errored when tput unavailable or non-TTY)
2026-07-17 06:32:12 -04:00
..
2026-07-16 01:39:12 -04:00

docker-stacks-update

Finds all running Docker Compose stacks, pulls the latest images, and restarts only the stacks that received updates.

Requirements

  • docker (with Compose v2 plugin — docker compose, not docker-compose)
  • jq — used to parse the JSON output of docker compose ls

Installation

Place the script anywhere in your $PATH, for example:

cp docker-stacks-update ~/.local/bin/
chmod +x ~/.local/bin/docker-stacks-update

Usage

docker-stacks-update

Run from any directory — the script finds every running stack system-wide using docker compose ls.

What it does

  1. Discover — lists all running stacks with docker compose ls --format json
  2. Pull — runs docker compose pull for each stack
  3. Detect — checks whether any service image was actually downloaded (not just "already up to date")
  4. Restart — recreates containers with docker compose up -d only for stacks that received new images
  5. Orphan cleanup — any stack whose compose file(s) no longer exist on disk is torn down automatically
  6. Report — prints a summary showing updated (with service names), unchanged, orphaned (removed), and failed stacks