Last active
March 20, 2019 17:13
-
-
Save martijngastkemper/a9aff8968fe6a790ea08e528d248f008 to your computer and use it in GitHub Desktop.
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/sh | |
# Usage: bash list-ports.sh PRIVATE_PORT | |
# PRIVATE_PORT default 80 | |
privatePort=${1-80} | |
services=`docker-compose ps --service --filter "status=running" 2> /dev/null` | |
if [ -z "$services" ] | |
then | |
echo "❗️no running services found" >&2 | |
exit 1 | |
fi | |
echo Private port $privatePort | |
for service in $services | |
do | |
port=`docker-compose port $service $privatePort 2> /dev/null` | |
if [ $? -eq 0 ] && [ -n "$port" ] | |
then | |
echo $service: $port | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment