I started writing about Docker last week (see Using Docker Containers – Part 1 – Build a Full Fledged Nuxeo Image). Another thing I wanted to do was something similar to X Forwarding. This could become handy to debug test containers built by Jenkins for instance. Looking at different solutions, I realized there were a lot of possibilities out there. You can use SSH, VNC, Xpra, NX and more.

The quickest working solution for me was using Xvfb and VNC (I tried Xpra like on Docker's blog but could not make it work). I had two options here. I could keep on adding layers to an existing Dockerfile or I could create a new one. I chose to keep it minimal and built a new image based on the nuxeo/nuxeo image I built in the previous post.

To make this work I installed Xvfb and VNC. And to make it nicer to test I also added the OpenBox window manager and Firefox. Once everything was installed, I setup VNC with a hard-coded password (yep, I should probably find a better way) and added a new entry to the supervisor configuration file. It simply runs the startXvfb.sh.

# Nuxeo VNC
# This image runs Nuxeo, Postgresql, SSh server, Apache and VNC.
# VERSION 0.0.1
FROM nuxeo/nuxeo
MAINTAINER Laurent Doguin <[email protected]>
RUN apt-get install -y xvfb x11vnc openbox firefox
# Setup a password for vnc
RUN mkdir /.vnc
RUN x11vnc -storepasswd nuxeospirit ~/.vnc/passwd
# Expose default vnc port
# Add a script launching xvfb and x11vnc to supervisor configuration
RUN echo "[program:startxvfb]">> /etc/supervisor/conf.d/supervisord.conf
RUN echo "command=/bin/sh startXvfb.sh">> /etc/supervisor/conf.d/supervisord.conf
ADD startXvfb.sh startXvfb.sh

startXvfb.sh is a very simple script that starts a Xvfb session on the :1 display with the OpenBox window manager then starts the vnc server on display :1.

Xvfb :1 -extension GLX -screen 0 1024x780x24& DISPLAY=:1 /usr/bin/openbox-session&
x11vnc -usepw -display :1
exit 0

You can build it with docker build -t nuxeo/nuxeoVNC. Just make sure you've already built the one it's based on (nuxeo/nuxeo).

You can run this container like the one it's based on:

docker run -d -P nuxeo/nuxeoVNC

And now you can use any VNC client to connect to it. Just remember that the port is not 5900 but the one mapped by the Docker. You'll be prompted for a password. It's 'nuxeospirit', the one hard-coded on the Dockerfile.

For information about the Nuxeo Platform, please visit our product page or request a custom demo to see how we can help your organization.