× Toggle menu

Setup a X11 desktop on your Devbox OpenVZ Container

This is a guest post by Michael Champigny. Michael is a member of the technical staff at SimpliVity and a researcher in parallel programming models, dynamic scheduling, and distributed computing.

If you have the need to run an X11 desktop on your DevBox or any other OpenVZ Container, it is now possible to do so using the new Direct Port feature of DevBoxes. The basic idea is to run a virtual X11 frame buffer on the DevBox and associate a VNC server with this virtual instance.

As a developer, this will give you a mechanism to develop and test native desktop applications on your DevBox. But this also provides you with a lightweight desktop environment running remotely on the DevBox whenever you need it.

To start with, create a C/C++ DevBox based on Ubuntu. I did not try CentOS though in theory you could adapt these instructions to work there. It may also be possible to start with a blank DevBox to save some disk space.

Install the following packages:
$ sudo apt-get update
$ sudo apt-get install Xvfb
$ sudo apt-get install x11vnc
$ sudo apt-get install wm2
$ sudo apt-get install scrot

Run an X server with a virtual frame buffer. I chose a small frame buffer with a visual depth of 16-bits but you could experiment with a larger frame buffer size and depth.

$ Xvfb :0 -ac -screen 0 800x600x16 &

We'll now run a very minimal window manager and xterm on the X server:

$ DISPLAY=:0 wm2 &
$ DISPLAY=:0 xterm &

We can capture the virtual frame buffer to verify the X server is running:

$ DISPLAY=:0 scrot screen.png

Refresh the DevBox in the Editor file explorer panel and click file screen.png. You should see a simple desktop with an xterm window.

Now run a VNC server associated with the X server:

$ x11vnc -nopw -localhost -display :0

Download your private key from the Codeanywhere editor to your local machine and change the file permissions:

$ chmod 600 codeanywhere.pem

From your DevBox Box info you'll need to obtain the SSH port and DNS information. The SSH port will change each time you start a DevBox unless it is marked as "Always On".

Now we'll use SSH on your local machine to tunnel the remote x11vnc server port through a local port. From a terminal on your local Linux or Mac machine - not your DevBox! :

$ ssh -L 5900:localhost:5900 cabox@ssh.{DEVBOX-DNS} -p {DEVBOX-SSH-PORT} -i codeanywhere.pem

Point a local VNC client to host "localhost" on port 5900 and you'll see your X11 desktop on the DevBox! I'm sure you'll find many interesting uses for this.

Log in now and start testing your DevBoxes Desktop

*Tested with RealVNC

Ready to start coding from anywhere?

Join the growing community of over ... businesses and professionals that already use Codeanywhere on a daily basis, and you can start coding from anywhere for free.

Sign up for free