Skip to content

Commit 7af1254

Browse files
add docker.host.internal to /etc/hosts
1 parent 5e2af80 commit 7af1254

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
function fix_linux_internal_host() {
4+
DOCKER_INTERNAL_HOST="host.docker.internal"
5+
6+
if ! grep $DOCKER_INTERNAL_HOST /etc/hosts > /dev/null ; then
7+
DOCKER_INTERNAL_IP=`/sbin/ip route|awk '/default/ { print $3 }'`
8+
echo -e "$DOCKER_INTERNAL_IP\t$DOCKER_INTERNAL_HOST" | tee -a /etc/hosts > /dev/null
9+
echo 'Added $DOCKER_INTERNAL_HOST to hosts /etc/hosts'
10+
fi
11+
}
12+
13+
fix_linux_internal_host

0 commit comments

Comments
 (0)