Skip to content

Instantly share code, notes, and snippets.

@smola
Created September 2, 2021 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smola/c280c536a4db612885260b403abc76eb to your computer and use it in GitHub Desktop.
Save smola/c280c536a4db612885260b403abc76eb to your computer and use it in GitHub Desktop.
Continuously tail logs for all Docker containers.
#!/bin/bash
set -eu
_shutdown() {
for pid in $(jobs -p); do
kill $pid || true
done
}
trap _shutdown EXIT
seen=""
while true; do
for cid in $(docker ps -q); do
if [[ ! " $seen " =~ " $cid " ]]; then
export seen="$seen $cid"
docker logs -f $cid &
fi
done
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment