Skip to content

Instantly share code, notes, and snippets.

@dublado
Created October 14, 2023 16:28
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 dublado/a0e0f8fdc8eaf7b62e4f061f097eca07 to your computer and use it in GitHub Desktop.
Save dublado/a0e0f8fdc8eaf7b62e4f061f097eca07 to your computer and use it in GitHub Desktop.
docker log size container list
#!/bin/bash
# Get list of all container IDs
container_ids=$(docker ps -q)
# Iterate through each container ID
for id in $container_ids; do
# Get container name for better readability
container_name=$(docker inspect --format='{{.Name}}' $id | sed 's/\///')
# Get log path
log_path=$(docker inspect --format='{{.LogPath}}' $id)
# Get log size
log_size=$(ls -lh $log_path | awk '{print $5}')
echo "Container: $container_name, Log Size: $log_size"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment