Running XNAT Virtual Machine in VirtualBox

VirtualBox is a powerful, open-source virtualization tool. It is available free of cost for Windows, OS X, Linux, and Solaris. VirtualBox offers features such as mouse intergration and folder sharing.

VirtualBox can create and run a virtual machine using a VMDK file, which is the format of the XNAT virtual machine.  Just follow the steps below:

Step 1) Install VirtualBox

Download here.

Step 2) Download and Unzip the VM

Download here (You can unzip w/ the free 7-zip utility).

Step 3) Launch VirtualBox

Step 4) Create a new Virtual Machine (aka VM)

Click on the “New” button in the main VirtualBox screen, so that the “Create New Virtual Machine” Wizard appears. Click “Next.”

Step 5) Basic Information

Give the VM a name, such as xnat-demo. For Operating System, select Linux, and for Version, select Ubuntu (please do not select Ubuntu 64 even if you are using a 64-bit computer, we will run a 32-bit guest). Click “Next.”

Step 6) Configure Memory

Set up the memory (512 MB should work for the demo). Click “Next.”

Step 7) Register the Pre-built Virtual Hard Drive

Click “Use existing hard disk” then click the icon to the right.

Browse to the location where you extracted the VMDK file and choose it.

The VMDK should appear in the list.  Click "Next".

Step 8) Finish VM Creation

The Virtual Machine is now ready, click “Create.”

Step 9) Launch the Virtual Machine

From the main window, with xnat-demo selected, click the “Start” button.

Step 10) Log in

The password can be found in the README file that accompanied the VMDK.

Step 11) Use the Virtual Machine

You can launch Firefox, XNAT should be running and configured with sample data at http://localhost:8080/xnat (there's a shortcut on the Bookmarks bar). The XNAT administrator's username is “admin” and its password is “admin”.

Optional: Open ports to allow other computers to connect to the XNAT VM

By default, VirtualBox uses a network configuration, in which the guest operating system (the XNAT VM) is not directly on the network, but rather shares the the host operating system's IP address. This configuration is much simpler than other possible options, but it comes at the expense of making it harder to expose a server port on the VM to the rest of the network.

However, VirtualBox makes it easy to route traffic from a port on the host to a port on the guest. Assuming that we named our Virtual Machine "xnat-demo", we can run the following commands at the host's command line which takes traffic from the host's port 8080 and directs it to the guest's port 8080.

VBoxManage modifyvm "xnat-demo" --natpf1 "ForwardXNATWebapp,tcp,,8080,,8080"

Alternatively, you can set up the port forwarding rule via the VirtualBox GUI (under Network-->Advanced–>Port Forwarding):

After implementing this, http://host-ip:8080/xnat will be directed to the VM's port 8080 (where Tomcat is listening for requests).