Created
July 22, 2023 16:07
-
-
Save miraculixx/d2d3aaa9fd9057cb5d15b196edce40d5 to your computer and use it in GitHub Desktop.
grep all docker logs
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 | |
# 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