Created
June 3, 2019 14:42
-
-
Save fullkomnun/452c2e4d9c608b78136989edb84a8ae5 to your computer and use it in GitHub Desktop.
A bash script that writes all logs from running docker containers to files called <container_name>.log and compresses these into an archive
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 -xe | |
for name in $(docker ps --format "{{.Names}}"); do | |
eval "docker logs \"$name\" 2> ${name}.log"; | |
done | |
eval "env GZIP=-9 tar cvzf logs.tar.gz *.log" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On a Mac the compressing can be done using:
'tar -czf logs.tar.gz --options gzip:compression-level=9 *.log'