Skip to content

Instantly share code, notes, and snippets.

@marcingrzejszczak
Created December 18, 2015 23: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 marcingrzejszczak/49e500522753a48aced5 to your computer and use it in GitHub Desktop.
Save marcingrzejszczak/49e500522753a48aced5 to your computer and use it in GitHub Desktop.
Cat X lines of running docker containers
#!/bin/bash
NUMBER_OF_LINES_TO_LOG=200
docker ps | sed -n '1!p' > /tmp/containers.txt
while read field1 field2 field3; do
echo -e "\n\nContainer name [$field2] with id [$field1] logs: \n\n"
docker logs --tail=$NUMBER_OF_LINES_TO_LOG -t $field1
done < /tmp/containers.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment