Skip to content

Instantly share code, notes, and snippets.

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

Dzhuneyt commented Jan 5, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment