Created
April 28, 2025 10:04
-
-
Save stefanpejcic/bd4a0bf86e7e441c3cfca8a75cf84124 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
log_dir="/var/lib/docker/containers" | |
echo "Container Name | Log Size" | |
echo "--------------------------" | |
for log_file in "$log_dir"/*/*-json.log; do | |
container_id=$(basename "$(dirname "$log_file")") | |
container_name=$(docker inspect --format='{{.Name}}' "$container_id" 2>/dev/null | sed 's/^\/\(.*\)/\1/') | |
if [ -z "$container_name" ]; then | |
continue | |
fi | |
log_size=$(du -h "$log_file" | cut -f1) | |
echo "$container_name | $log_size" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment