Last active
January 27, 2021 16:21
-
-
Save dvarrazzo/e8ddbfe1409da221080ca8c85e70c740 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/bash | |
# Return the ip address for a container in docker-compose | |
set -euo pipefail | |
# set -x | |
if [[ "${1:-}" == "" ]]; then | |
echo "usage: $0 container | |
Error: container name needed. | |
" >&2 | |
exit 2 | |
fi | |
container=$(docker-compose ps -q "$1") | |
docker inspect "$container" \ | |
| jq -r '[.[0].NetworkSettings.Networks[] | .IPAddress][0]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment