Skip to content

Instantly share code, notes, and snippets.

@dvarrazzo
Last active January 27, 2021 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvarrazzo/e8ddbfe1409da221080ca8c85e70c740 to your computer and use it in GitHub Desktop.
Save dvarrazzo/e8ddbfe1409da221080ca8c85e70c740 to your computer and use it in GitHub Desktop.
#!/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