Last active
August 29, 2015 14:04
-
-
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
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
# $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