Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed docker host option for wsl2 #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,13 @@ edi_does_container_exist() {
}

edi_docker_host_option() {
if [[ "$OSTYPE" == "linux-gnu" ]]
then
# Linux
DOCKERHOST=`ip addr show docker0 | grep inet | head -n 1 | awk '{ print $2 }' | grep -oP "^[^/]+"`
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
if [[ "$OSTYPE" == "darwin"* ]] || [ $(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip') ]; then
# Mac OSX and WSL2
# Solution found via https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach
DOCKERHOST=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
DOCKERHOST=`ip addr show docker0 | grep inet | head -n 1 | awk '{ print $2 }' | grep -oP "^[^/]+"`
fi
echo "--add-host host:$DOCKERHOST "
}
Expand Down
11 changes: 5 additions & 6 deletions bin/edi
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,13 @@ edi_does_container_exist() {
}

edi_docker_host_option() {
if [[ "$OSTYPE" == "linux-gnu" ]]
then
# Linux
DOCKERHOST=`ip addr show docker0 | grep inet | head -n 1 | awk '{ print $2 }' | grep -oP "^[^/]+"`
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
if [[ "$OSTYPE" == "darwin"* ]] || [ $(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip') ]; then
# Mac OSX and WSL2
# Solution found via https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach
DOCKERHOST=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
DOCKERHOST=`ip addr show docker0 | grep inet | head -n 1 | awk '{ print $2 }' | grep -oP "^[^/]+"`
fi
echo "--add-host host:$DOCKERHOST "
}
Expand Down
11 changes: 5 additions & 6 deletions bin/eds
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,13 @@ edi_does_container_exist() {
}

edi_docker_host_option() {
if [[ "$OSTYPE" == "linux-gnu" ]]
then
# Linux
DOCKERHOST=`ip addr show docker0 | grep inet | head -n 1 | awk '{ print $2 }' | grep -oP "^[^/]+"`
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
if [[ "$OSTYPE" == "darwin"* ]] || [ $(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip') ]; then
# Mac OSX and WSL2
# Solution found via https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach
DOCKERHOST=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
DOCKERHOST=`ip addr show docker0 | grep inet | head -n 1 | awk '{ print $2 }' | grep -oP "^[^/]+"`
fi
echo "--add-host host:$DOCKERHOST "
}
Expand Down