Created
September 2, 2021 11:43
-
-
Save smola/c280c536a4db612885260b403abc76eb to your computer and use it in GitHub Desktop.
Continuously tail logs for all Docker containers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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