Created
January 5, 2020 16:01
-
-
Save Dzhuneyt/e75ff1a18d6243c384bc07864986eabf to your computer and use it in GitHub Desktop.
Tail log of a Docker Swarm stack
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 -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)