Skip to content

Commit

Permalink
Update entrypoint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
qoomon authored Nov 9, 2018
1 parent cefba3e commit d87c767
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
set -e

DOCKER_HOST="$(getent hosts host.docker.internal | cut -d' ' -f1)"
if [ ! $DOCKER_HOST ]; then
if [ $DOCKER_HOST ]; then
echo "Docker Host: $DOCKER_HOST (host.docker.internal)"
else
DOCKER_HOST=$(ip -4 route show default | cut -d' ' -f3)
echo "Docker Host: $DOCKER_HOST (default gateway)"
fi

FORWARDING_PORTS=${PORTS:-'0:65535'}
echo "Docker Host: $DOCKER_HOST"

iptables -t nat -I PREROUTING -p tcp --match multiport --dports "$FORWARDING_PORTS" -j DNAT --to-destination $DOCKER_HOST
iptables -t nat -I POSTROUTING -j MASQUERADE
Expand Down

0 comments on commit d87c767

Please sign in to comment.