Skip to content

Instantly share code, notes, and snippets.

@charlesmarshall
Last active August 29, 2015 14:04
Show Gist options
  • Save charlesmarshall/e50c00857fe7bb3af0d7 to your computer and use it in GitHub Desktop.
Save charlesmarshall/e50c00857fe7bb3af0d7 to your computer and use it in GitHub Desktop.
Use a service name to find the ip & port that its running on
# $1 = service name
# $2 = service internal port
getServiceIPAndPort(){
local id=$(docker ps -a | grep "\( ${1}\)" | awk '{ print $1 }')
local port=$(docker port $id $2 | sed -r 's#0.0.0.0:##gi')
if [[ -z $port ]]; then
sleep 5
getServiceIPAndPort "${1}" "${2}"
fi
echo "${COREOS_PRIVATE_IPV4}:${port}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment