Tail log of a Docker Swarm stack
This file contains 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 -e | |
stack=$1 | |
if [ -z "${stack}" ]; then | |
echo 'Usage:' | |
echo "$0 <stack>" | |
exit 1 | |
fi | |
# Get a list of the service names | |
services=$(docker stack services --format {{.Name}} ${stack}) | |
# Sort the service names | |
services=$(echo "${services}" | sort) | |
# Create the command to run | |
command='multitail -s 2' | |
for service in ${services}; do | |
command="${command} -l 'docker service logs -f ${service}'" | |
done | |
# Run the command | |
bash -c "${command}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: moby/moby#31458 (comment)