Skip to content

Instantly share code, notes, and snippets.

@aleksandar-babic
Created June 6, 2018 13:38
Show Gist options
  • Save aleksandar-babic/3d1464f62676c9343e352b1f1049a34c to your computer and use it in GitHub Desktop.
Save aleksandar-babic/3d1464f62676c9343e352b1f1049a34c to your computer and use it in GitHub Desktop.
Script returns ID of first container for given service in Docker Swarm Mode
#!/usr/bin/env bash
if [[ $# -eq 0 ]] ; then
echo 'usage: ./get-first-swarm-container.sh service-name'
exit 1
fi
docker ps | grep $1 | awk '{print $1}' | head -n 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment