Created
March 11, 2020 21:55
-
-
Save gnuns/c748c46a4027142bafc99e539f7a0593 to your computer and use it in GitHub Desktop.
Docker host.docker.internal on Linux
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
# IP do host | |
ifeq ($(UNAME), Linux) | |
HOST_IP := $(shell ip -o route get 1 | sed -e 's/.*src \([0-9\.]*\).*/\1/') | |
endif | |
ifeq ($(UNAME), Darwin) | |
HOST_IP := $(shell ifconfig | grep ^en0 -A15 | grep "inet " | tail -1 | awk '{print $$2}') | |
endif | |
echo "$(HOST_IP) host.docker.internal" | docker exec -i container_name /usr/bin/tee -a /etc/hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment