I run my homelab on Docker Compose where all my files are located in a /hom/data/docker-compose/**/docker-compose.yaml
structure.
To update these containers I often just, every two weeks, go into each folder, run docker-compose pull && docker-compose up -d
and then run docker image prune
to remove dangling images afterwards.
There are alternatives like watchtower which auto update these outdated images, but for something as critical as my homelab components I like to be in control manually.
Partly that is.
Here is a quick bash script I boggled together that does that for each docker-compose.yaml config found in a given folder:
bash#!/usr/bin/env bashreadarray -d '' composeConfigs < <(find . -type f -name docker-compose.y* -print0)for cfg in "${composeConfigs[@]}"; dodocker-compose -f "$cfg" pulldocker-compose -f "$cfg" up -ddonedocker image prune
Run it with /home/data/docker-compose/update_containers.sh
or put it in a cron job 🐳.
Full demo on my Github demo collection.
This script can optionally take a parameter to make the folder adjustable instead of running in current dir. I keep it in the same folder so didn't bother.