Skip to content

Instantly share code, notes, and snippets.

@gnuns
Created March 11, 2020 21:55
Show Gist options
  • Save gnuns/c748c46a4027142bafc99e539f7a0593 to your computer and use it in GitHub Desktop.
Save gnuns/c748c46a4027142bafc99e539f7a0593 to your computer and use it in GitHub Desktop.
Docker host.docker.internal on Linux
# 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