Skip to content

Commit 63c9548

Browse files
committed
/etc/hosts hack no longer necessary since docker >= 1.2.0
1 parent 7067347 commit 63c9548

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ RUN chmod +x /opt/selenium/local-sel-headless.sh
117117
#===========
118118
# DNS stuff
119119
#===========
120-
# Poor man /etc/hosts updates until https://github.com/dotcloud/docker/issues/2267
121-
# Ref: https://stackoverflow.com/questions/19414543/how-can-i-make-etc-hosts-writable-by-root-in-a-docker-container
122120
ADD ./etc/hosts /tmp/hosts
123-
RUN mkdir -p -- /lib-override && cp /lib/x86_64-linux-gnu/libnss_files.so.2 /lib-override
124-
RUN perl -pi -e 's:/etc/hosts:/tmp/hosts:g' /lib-override/libnss_files.so.2
125-
ENV LD_LIBRARY_PATH /lib-override
121+
# Below hack is no longer necessary since docker >= 1.2.0, commented to ease old users transition
122+
# Poor man /etc/hosts updates until https://github.com/dotcloud/docker/issues/2267
123+
# Ref: https://stackoverflow.com/questions/19414543/how-can-i-make-etc-hosts-writable-by-root-in-a-docker-container
124+
# RUN mkdir -p -- /lib-override && cp /lib/x86_64-linux-gnu/libnss_files.so.2 /lib-override
125+
# RUN perl -pi -e 's:/etc/hosts:/tmp/hosts:g' /lib-override/libnss_files.so.2
126+
# ENV LD_LIBRARY_PATH /lib-override
126127

127128
#============================
128129
# Some configuration options

bin/entry_point.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
33
export CONTAINER_IP=$(ip addr show dev eth0 | grep "inet " | awk '{print $2}' | cut -d '/' -f 1)
44
export DOCKER_HOST_IP=$(netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}')
5+
export VNC_PORT=5900
56
export XVFB_LOG="/tmp/Xvfb_headless.log"
67
export FLUXBOX_LOG="/tmp/fluxbox_manager.log"
7-
export X11VNC_LOG="/tmp/x11vnc_forever.log"
8+
export VNC_LOG="/tmp/x11vnc_forever.log"
9+
export XTERMINAL_LOG="/tmp/local-sel-headless.log"
10+
11+
# As of docker >= 1.2.0 is possible to append our stuff directly into /etc/hosts
12+
cat /tmp/hosts >> /etc/hosts
13+
echo "docker.host.dev $DOCKER_HOST_IP" >> /etc/hosts
14+
echo "docker.guest.dev $CONTAINER_IP" >> /etc/hosts
815

916
# Start the X server that can run on machines with no display
1017
# hardware and no physical input devices
@@ -20,7 +27,7 @@ sleep 0.5
2027

2128
# Start a GUI xTerm to easily debug the headless instance
2229
x-terminal-emulator -geometry 100x30+10+10 -ls -title "local-sel-headless" \
23-
-e "/opt/selenium/local-sel-headless.sh" &
30+
-e "/opt/selenium/local-sel-headless.sh" 2>&1 | tee $XTERMINAL_LOG &
2431

2532
# Start VNC server to enable viewing what's going on but not mandatory
26-
x11vnc -forever -usepw -display $DISPLAY >$X11VNC_LOG 2>&1
33+
x11vnc -forever -usepw -shared -rfbport $VNC_PORT -display $DISPLAY >$VNC_LOG 2>&1

bin/local-sel-headless.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env bash
22

33
sudo -E -i -u user1 \
4-
LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
54
DOCKER_HOST_IP=$DOCKER_HOST_IP \
65
java -jar /opt/selenium/selenium-server-standalone.jar -port $SELENIUM_PORT

0 commit comments

Comments
 (0)