1.2 KiB
1.2 KiB
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, notdocker-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
- Discover — lists all running stacks with
docker compose ls --format json - Pull — runs
docker compose pullfor each stack - Detect — checks whether any service image was actually downloaded (not just "already up to date")
- Restart — recreates containers with
docker compose up -donly for stacks that received new images - Orphan cleanup — any stack whose compose file(s) no longer exist on disk is torn down automatically
- Report — prints a summary showing updated (with service names), unchanged, orphaned (removed), and failed stacks