The LXD demo server is a great showcase for LXD containers, but it’s also quite useful when you want to spin up an temporary container.

While LXD makes spinning up Linux containers extremely simple, sometimes you want something even simpler. You just want to drop directly into a vm and you don’t want to worry about cleaning up after yourself. Running LXD Demo Server on your Ubuntu Core device is perfect for this use case. To be clear, the LXD Demo Server was mainly designed for demoing LXD, but in this post we’ll show you how to tweak it a bit to make it into a disposable VM server.

You also might considering installing this on a Raspberry Pi. This give you quick access to ARM based vm’s for testing.

Step 0: Install LXD

Unless otherwise noted all the command in this post will need to be run on your ubuntu core device. If you’re running on a physical device (like a raspberry pi) you’ll want to ssh into it,

Before you can install LXD Demo Sever you should make sure you have the LXD snap installed. You can install it with the following command:

sudo snap install lxd

And then initialize it with:

sudo lxd init

You can accept all the defaults with initialize it.

Step 1: Installing LXD Demo Server

Installing the demo server is even easier than installing lxd. Simply run the following command:

sudo snap install lxd-demo-server

And that’s it! Next let’s test it to make sure it’s all working.

Step 2: Give it a spin

At this point it should be ready use. However, because by default it uses a pretty common port (8080), it is possible that something else is listening on this port. If that is the case we’ll fix it in the next step. To give it a spin, open your web browser and point it to http://<ubuntu-core-ip-address>:8080/.

Assuming all is working properly you’ll see something like this: lxd demo server web ui

If this is not what you see, make sure you change the port the server is using in the next step.

Step 3: Configuration

The most difficult part of configuring the demo server is using vim. :P (But seriously if you need a bit of a vim refresher, or quick start, this tutorial’s not bad )

To configure the server type the command sudo lxd-demo-server.configure. This will open a config file with vim. Make the following changes to the file:

  1. If you ran into port a conflict while testing it, in step 2, change the “8080” to a free post. on the line that looks like this: server_addr: "[::]:8080"
  2. By default each vm session can only last 30 minutes (or 1800 seconds). This might be fine for a demo but it’s a bit short for our purposes. You’ll want to increase it to something longer, but not so long that the vms pile up and take a too much time to get cleaned up. I would say somewhere between 2 and 12 hours. Change this line quota_time: 1800 to something like 18000.
  3. By default you can only have two session open from the same computer at a time, which is also a bit small for our purposes. Changes quota_sessions: 2 to 10 sessions.

Once, you’ve finished editing the config file, save it. The server will automatically pick up these changes. Open browser and test the server again (make sure to update the port if you have changed it).

And that’s it! You now have a server where you can open quick disposable zero-config VMs at the click of a button. Happy hackings.