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

Updated support-scripts edi_docker_host_option #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 12 additions & 4 deletions support-scripts
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,25 @@ edi_does_container_exist() {
}

edi_docker_host_option() {
if [[ "$OSTYPE" == "linux-gnu" || "$OSTYPE" == "linux" ]]
if [[ "$OSTYPE" == "linux"* ]]
then
# Linux
DOCKERHOST=`ip addr show docker0 | grep inet | head -n 1 | awk '{ print $2 }' | grep -oP "^[^/]+"`
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
# 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)
else
echo "OS TYPE $OSTYPE not understood"
exit 1
fi

if [ -z "$DOCKERHOST" ]
then
# Normally echos would be used to not have all the info on one line in read -p,
# but considering that echo is used to build the command, that is not possible here.
default="172.17.0.1"
read -p $'Docker host could not be determined
Please manually enter the IP of your docker0 bridge connection
docker0 ip '"[$default]: " DOCKERHOST
DOCKERHOST=${DOCKERHOST:-$default}
fi
echo "--add-host host:$DOCKERHOST "
}
Expand Down