Skip to content

Instantly share code, notes, and snippets.

@SeanSyue
Created May 4, 2020 09:07
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 SeanSyue/280f0083330034cb9add99972ff6ea94 to your computer and use it in GitHub Desktop.
Save SeanSyue/280f0083330034cb9add99972ff6ea94 to your computer and use it in GitHub Desktop.
###### Get docker machine ip ######
# able to resolve docker ip for both Docker Toolbox and Docker Desktop
if [[ -z "${DOCKER_HOST_IP-}" ]]; then
docker_host_ip=$(docker run --rm --net host alpine ip address show eth0 | awk '$1=="inet" {print $2}' | cut -f1 -d'/')
# Work around Docker for Mac 1.12.0-rc2-beta16 (build: 9493)
if [[ $docker_host_ip = '192.168.65.2' ]]; then
docker_host_ip=$(/sbin/ifconfig | grep -v '127.0.0.1' | awk '$1=="inet" {print $2}' | cut -f1 -d'/' | head -n 1)
fi
export DOCKER_HOST_IP=$docker_host_ip
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment