Skip to content

Commit f25f642

Browse files
author
Frank Carey
committed
Issue #22: Create a Docker image.
* After much debugging, it seems xvfb (virtual frame buffer) needed to be implemented to get opengl working properly. * Switched to using our own from-stratch Dockerfile based on Ubuntu 14.04 * Switched to x11vnc instead of tightvnc since tightvnc didn't seem to work, but not sure if that's still an issue or not. * Added lots of documentation around the various settings used. * Using fluxbox instead of lxdm because it was lighter weight.
1 parent 82dd0d7 commit f25f642

File tree

3 files changed

+86
-34
lines changed

3 files changed

+86
-34
lines changed

.docker/startup.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Remove VNC lock (if process already killed)
4+
rm -f /tmp/.X1-lock /tmp/.X11-unix/X1
5+
6+
# Set the DISPLAY that will be used by default. Makes lab show up in our xvfb display
7+
export DISPLAY=:1
8+
9+
# Start the X virtual frame buffer which uses memory instead of an actual device.
10+
# Allows lab to be run headless.
11+
Xvfb "$DISPLAY" -screen 0 "$XVFB_RESOLUTION" &
12+
13+
# Run a lightweight Window Manager (fluxbox is smaller than lxdm, gnome, unity, kde, etc)
14+
# (pretty sure this is required.)
15+
fluxbox &
16+
17+
# Run the x11vnc server
18+
# Explanation of options:
19+
# -display : This needs to match the xvfb display number
20+
# -passwd : Use the password from an ENV var here instead of using ~/.vnc/passwd
21+
# -o : Specifies where to send the log output.
22+
# -noipv6 : Skip trying to serve vnc on ipv6 (avoids warnings)
23+
# -bg : Run in the background
24+
# -forever : Don't die when the first user disconnects from vnc (which is the default)
25+
# -N : Makes it use port 5900+N where N is the display.. so 5901. (default is 5900)
26+
x11vnc \
27+
-display "$DISPLAY" \
28+
-passwd "$VNC_PASSWORD" \
29+
-o /dev/stderr \
30+
-noipv6 \
31+
-bg \
32+
-forever \
33+
-N

Dockerfile

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1-
FROM kaixhin/vnc
1+
FROM ubuntu:14.04
22

33
MAINTAINER fcarey@gmail.com
44

5+
# Temporarily shut up warnings.
6+
ENV DISPLAY :0
7+
ENV TERM xterm
8+
9+
# Basic Dependencies
510
RUN apt-get update && apt-get install -y \
611
curl \
712
zip \
813
unzip \
914
software-properties-common \
1015
python-software-properties && \
11-
apt-get clean && \
12-
rm -rf /var/lib/apt/lists/*
16+
apt-get clean && \
17+
rm -rf /var/lib/apt/lists/*
18+
19+
# Dependencies for vnc setup.
20+
RUN apt-get update && apt-get install -y \
21+
xvfb \
22+
fluxbox \
23+
x11vnc && \
24+
apt-get clean && \
25+
rm -rf /var/lib/apt/lists/*
26+
1327

1428
# We need to add a custom PPA to pick up JDK8, since trusty doesn't
1529
# have an openjdk8 backport. openjdk-r is maintained by a reliable contributor:
@@ -18,13 +32,14 @@ RUN apt-get update && apt-get install -y \
1832
# finally backported to trusty; see e.g.
1933
# https://bugs.launchpad.net/trusty-backports/+bug/1368094
2034
RUN add-apt-repository -y ppa:openjdk-r/ppa && \
21-
apt-get update && \
22-
apt-get install -y openjdk-8-jdk openjdk-8-jre-headless && \
23-
apt-get clean && \
24-
rm -rf /var/lib/apt/lists/* && \
25-
which java && \
26-
java -version && \
27-
update-ca-certificates -f
35+
apt-get update && apt-get install -y \
36+
openjdk-8-jdk \
37+
openjdk-8-jre-headless && \
38+
apt-get clean && \
39+
rm -rf /var/lib/apt/lists/* && \
40+
which java && \
41+
java -version && \
42+
update-ca-certificates -f
2843

2944
# Running bazel inside a `docker build` command causes trouble, cf:
3045
# https://github.com/bazelbuild/bazel/issues/134
@@ -48,34 +63,44 @@ RUN mkdir /bazel && \
4863

4964
# Install deepmind-lab dependencies
5065
RUN apt-get update && apt-get install -y \
51-
lua5.1 \
52-
liblua5.1-0-dev \
53-
libffi-dev \
54-
gettext \
55-
freeglut3-dev \
56-
libsdl2-dev \
57-
libosmesa6-dev \
58-
python-dev \
59-
python-numpy \
60-
realpath \
61-
build-essential
66+
lua5.1 \
67+
liblua5.1-0-dev \
68+
libffi-dev \
69+
gettext \
70+
freeglut3-dev \
71+
libsdl2-dev \
72+
libosmesa6-dev \
73+
python-dev \
74+
python-numpy \
75+
realpath \
76+
build-essential && \
77+
apt-get clean && \
78+
rm -rf /var/lib/apt/lists/*
6279

63-
#Enable RANDR option for vnc server.
64-
COPY ./vnc.sh /opt/vnc.sh
6580

6681
# Set the default X11 Display.
6782
ENV DISPLAY :1
83+
ENV VNC_PASSWORD=password
84+
ENV XVFB_RESOLUTION=800x600x16
6885

86+
# Set up deepmind-lab folder and copy in the code.
6987
ENV lab_dir /lab
7088
RUN mkdir /$lab_dir
7189
COPY . /$lab_dir
7290
WORKDIR $lab_dir
7391

74-
RUN bazel build :deepmind_lab.so --define headless=osmesa
75-
76-
# RUN bazel run :python_module_test --define headless=osmesa
77-
78-
#RUN bazel run :random_agent --define headless=false
92+
# Run an actual (headless) build since this should make subsequent builds much faster.
93+
# Alternative commands based on the Documentation:
94+
# RUN bazel run :random_agent --define headless=false
95+
# RUN bazel build :deepmind_lab.so --define headless=osmesa
96+
RUN bazel run :python_module_test --define headless=osmesa
7997

98+
# This port is the default for connecting to VNC display :1
99+
EXPOSE 5901
80100

101+
# Copy VNC script that handles restarts and make it executable.
102+
COPY ./.docker/startup.sh /opt/
103+
RUN chmod u+x /opt/startup.sh
81104

105+
# Finally, start VNC using our script.
106+
CMD ["/opt/startup.sh"]

vnc.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)