Skip to content
bash script for development Consul clusters using LXD on Ubuntu 16.04 LTS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Want to experiment with Consul clusters or LXD containers? Look no further.

lxd-consul is a bash script that will spin up a consul cluster on Ubuntu 16.04 LTS utilizing lxd containers.

This script will start a 3 node consul cluster using LXD containers running Alpine Linux. Each node takes about 9MB space so its very lightweight and fast. Furthermore, the consul cluster data will persist if the system or container reboots without needing to create data mounts.

lxd-consul has only been tested on Ubuntu 16.04 and should be used for dev/testing purposes.

lxd-consul running in terminal


  • Ubuntu 16.04 LTS

  • LXD install -- howto

Installing lxd-consul

Clone the repo:

Change Directory: cd lxd-consul

Run the script: ./ create

At this point, the script will run, create containers, and return the IPs of the cluster.

To stop the cluster:

./ stop

To start the cluster:

./ start

To destroy the cluster:

./ destroy

When you reboot your computer or need to re-bootstrap the consul cluster simply run a restart:

./ restart

This will bring your cluster back and the data should still be persisted.

Why LXD instead of Docker?

LXD is a very easy to use/install virtualization solution for Ubuntu users. With LXD you get all the benefits of Docker like speed, portability, isolation, and performance. However, you gain a more familiar hypervisor experience as opposed to the somewhat opinionated Docker workflow. LXD is designed to run containers which are running full operating systems which allow you to treat the container like a vm. LXD containers are smaller than traditional VM images and since they are containers they run very close to the metal. For this script, I utilized Alpine OS images which are extraordinarily minimalist images using about 3MB of disk. Only potential downside is that LXD doesn't have a declarative configuration file (Dockerfile) or as great a mindshare/ecosystem as Docker.

Further Reading

I highly recommend reading about the ease and benefits of LXD here: LXD Tutorial

You can’t perform that action at this time.