Skip to content

Instantly share code, notes, and snippets.

@miraculixx
Created July 22, 2023 16:07
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 miraculixx/d2d3aaa9fd9057cb5d15b196edce40d5 to your computer and use it in GitHub Desktop.
Save miraculixx/d2d3aaa9fd9057cb5d15b196edce40d5 to your computer and use it in GitHub Desktop.
grep all docker logs
#!/bin/bash
# Get a list of running container IDs
container_ids=$(docker ps -q)
# Loop through each container and retrieve its logs
for container_id in $container_ids; do
container_name=$(docker inspect -f '{{ .Name }}' "$container_id" | cut -d'/' -f2)
echo "Container: $container_name"
docker logs "$container_id" 2>&1 | grep "$1" # Replace "SEARCH_PATTERN" with your desired pattern
echo "--------------------------------------------------"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment