Created
May 4, 2020 09:07
-
-
Save yuchen-xue/280f0083330034cb9add99972ff6ea94 to your computer and use it in GitHub Desktop.
Get docker machine ip. See more on: https://github.com/wurstmeister/kafka-docker/issues/110#issuecomment-238578767
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
###### 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