Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit de07be9

Browse files
committed
Fix DOCKER_HOST_IP and CONTAINER_IP (in OSX use docker.for.mac.localhost) #177
1 parent 0af564b commit de07be9

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

bin/entry.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fi
4242
# See: SeleniumHQ/docker-selenium/issues/14
4343
# Added a non-sudo conditional so this works on non-sudo environments like K8s
4444
if [ "${WE_HAVE_SUDO_ACCESS}" == "true" ]; then
45-
sudo haveged
45+
sudo -E haveged
4646
else
4747
haveged || true
4848
fi
@@ -112,6 +112,18 @@ export GEOMETRY="${SCREEN_WIDTH}""x""${SCREEN_HEIGHT}""x""${SCREEN_DEPTH}"
112112
export DOCKER_HOST_IP=$(netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}')
113113
export CONTAINER_IP=$(ip addr show dev ${ETHERNET_DEVICE_NAME} | grep "inet " | awk '{print $2}' | cut -d '/' -f 1)
114114

115+
# if [ "${DOCKER_HOST_IP}" == "" ] || [[ ${DOCKER_HOST_IP} == 127* ]]; then
116+
# # TODO: Try with an alternative method
117+
# # die "DOCKER_HOST_IP is '${DOCKER_HOST_IP}'"
118+
# # export DOCKER_HOST_IP=$(ip route show | awk '/default/ {print $3}')
119+
# fi
120+
121+
# if [ "${CONTAINER_IP}" == "" ] || [[ ${CONTAINER_IP} == 127* ]]; then
122+
# # TODO: Try with an alternative method
123+
# # die "CONTAINER_IP is '${CONTAINER_IP}'"
124+
# # export CONTAINER_IP=$(hostname -i)
125+
# fi
126+
115127
# Common capabilities for both nodes (Chrome/Firefox)
116128
export COMMON_CAPS="maxInstances=${MAX_INSTANCES}"
117129
export COMMON_CAPS="${COMMON_CAPS},platform=LINUX"
@@ -400,7 +412,7 @@ ga_track_start () {
400412
#--------------------------------
401413
# Improve etc/hosts and fix dirs
402414
if [ "${WE_HAVE_SUDO_ACCESS}" == "true" ]; then
403-
sudo improve_etc_hosts.sh
415+
sudo -E improve_etc_hosts.sh
404416
fi
405417

406418
#-------------------------
@@ -463,6 +475,9 @@ echo "${CUSTOM_SELENIUM_NODE_PROXY_PARAMS}" > CUSTOM_SELENIUM_NODE_PROXY_PARAMS
463475
echo "${CUSTOM_SELENIUM_NODE_REGISTER_CYCLE}" > CUSTOM_SELENIUM_NODE_REGISTER_CYCLE
464476
echo "${USE_KUBERNETES}" > USE_KUBERNETES
465477
echo "${XMANAGER}" > XMANAGER
478+
echo "${DOCKER_HOST_IP}" > DOCKER_HOST_IP
479+
echo "${CONTAINER_IP}" > CONTAINER_IP
480+
echo "${WE_HAVE_SUDO_ACCESS}" > WE_HAVE_SUDO_ACCESS
466481
echo "${GRID}" > GRID
467482

468483
# Open a new file descriptor that redirects to stdout:

dns/bin/improve_etc_hosts.sh

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
#!/usr/bin/env bash
22

3+
# Note: In OSX use docker.for.mac.localhost
4+
35
cat /tmp/hosts >> /etc/hosts
4-
echo "$DOCKER_HOST_IP docker.host" >> /etc/hosts
5-
echo "$CONTAINER_IP docker.guest" >> /etc/hosts
6-
echo "$DOCKER_HOST_IP docker.host.dev" >> /etc/hosts
7-
echo "$DOCKER_HOST_IP d.host.loc.dev" >> /etc/hosts
8-
echo "$CONTAINER_IP docker.guest.dev" >> /etc/hosts
9-
echo "$DOCKER_HOST_IP host.docker.local" >> /etc/hosts
10-
echo "$CONTAINER_IP guest.docker.local" >> /etc/hosts
11-
echo "$CONTAINER_IP d.guest.loc.dev" >> /etc/hosts
12-
echo "$DOCKER_HOST_IP host.docker" >> /etc/hosts
13-
echo "$CONTAINER_IP guest.docker" >> /etc/hosts
6+
7+
if [ "${DOCKER_HOST_IP}" != "" ]; then
8+
echo "${DOCKER_HOST_IP} docker.host" >> /etc/hosts
9+
echo "${DOCKER_HOST_IP} docker.host.dev" >> /etc/hosts
10+
echo "${DOCKER_HOST_IP} d.host.loc.dev" >> /etc/hosts
11+
echo "${DOCKER_HOST_IP} host.docker.local" >> /etc/hosts
12+
echo "${DOCKER_HOST_IP} host.docker" >> /etc/hosts
13+
fi
14+
15+
if [ "${CONTAINER_IP}" != "" ]; then
16+
echo "${CONTAINER_IP} docker.guest" >> /etc/hosts
17+
echo "${CONTAINER_IP} docker.guest.dev" >> /etc/hosts
18+
echo "${CONTAINER_IP} guest.docker.local" >> /etc/hosts
19+
echo "${CONTAINER_IP} d.guest.loc.dev" >> /etc/hosts
20+
echo "${CONTAINER_IP} guest.docker" >> /etc/hosts
21+
fi

0 commit comments

Comments
 (0)