Your submission was sent successfully! Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

Open source for beginners: setting up your dev environment with LXD

If you are a developer, or even just a person generally interested in technology, you already know that cloud computing is what keeps the wheels turning today. It emerged as a way to run things more efficiently and reduce the burden of infrastructure management. There are many tools you can use to develop, test, deploy and integrate systems in the cloud, be it private or public, and there is no right or wrong way to go about learning this. In the “Open source for beginners” blog series, we go over some of the valuable open-source tools or infrastructure options that can help get you started on your cloud journey.

LXD is one such versatile tool. It’s great for both people that are just starting and organisations that are looking for a resource-efficient way to develop and deploy their systems. Are you looking for a way to practice your Linux commands without jeopardizing your underlying system? Want to practice running complex infrastructure use cases? Perhaps you’d like to understand how the application you develop on your laptop would behave on a cloud instance. LXD is likely the right choice. 

Setting up a secure and resource-efficient dev environment 

There is a big variety of tools, languages and systems you could use for development and experimentation. As you evolve as a developer, you’re likely to experiment with many of them and your process will change and adapt over time. To accommodate this, you’d want your underlying infrastructure to be flexible, safe and resource-efficient. 

Flexible infrastructure would allow you to test different tools, integrations and workloads at different scales. From spinning up a simple container for testing things to running hundreds of them in a highly-available edge cluster integrated with various orchestration tools – you’d want your underlying infrastructure to be easily adaptable to whatever you’re currently working on, as well as capable of scaling once you need it.

Security and safety are important as well. As you’re starting, you’re likely not to have dedicated machines for experimentation, but rather you would use your regular computer. Therefore, you should have your dev environment running as isolated as possible, in order to make sure that mistakes don’t affect the rest of your data. 

As you’re starting, you also need a resource-efficient infrastructure that allows you to do a lot with limited resources. The ability to run many instances just on your laptop, without it affecting your memory and compute power, is very valuable, giving you space to learn efficiently. This applies to production as well – from edge applications to a fully functional data center – resource-efficient infrastructure is essential.

Enter LXD

LXD is a great option for your development (as well as production) infrastructure. It supports everything you need to run your virtualised workloads. You can use it for lightweight and constrained disposable testing environments for everything running from experimenting with Linux and testing applications, to simulating or testing complex infrastructure processes.

With LXD, you can run system containers that simulate a full operating system without the overhead of regular hardware virtualisation, or you can run regular virtual machines. When it comes to storage, networking, and logging, LXD supports a variety of interfaces and features that the user can control and interact with. The containers are unprivileged by default, making sure whatever you’re working on is run in a safe environment not affecting the rest of your workloads. Overall, functionality-wise, LXD is similar to VMWare or KVM hypervisors, but is much lighter on resources and removes the usual virtualisation overhead, making it a great choice for both development and production environments. 

How it works

LXD is image-based, and it has an intuitive CLI, making it fairly easy to interact with. Spinning up an instance, whether it’s a container or a VM, takes seconds and you can choose from various distributions. As mentioned above, LXD system containers are extremely resource-efficient. This makes LXD a powerful tool, even if you run it only on your own computer. 

While just having a container where you can install and test something, or just use it to learn Linux commands, might be enough for you initially, LXD can be very useful if you’re interested in experimenting with more advanced stuff or simulating how your workloads would run in production (including on the public clouds). As an example, let’s say you are working with an enterprise-grade system that is hosted in one of the public clouds. You could easily run a duplicate on your local machine in a resource-efficient way, allowing you to develop and test new features, without having to pay for a designated development instance in the cloud you’re using.

For a complete experience, LXD has available integrations with a variety of other infrastructure tools, enabling you to learn those, in addition to LXD. These are: Juju, MAAS, Ansible, Terraform, Puppet Bolt, and Packer.

How to get started

LXD is very easy to set up. Four simple steps are all it takes to get ready to run workloads:

  1. If you have Ubuntu 16.04 or above, just run snap install lxd to install LXD.
  2. Then run lxd init to  to configure your LXD instance (default options are sufficient in many cases).
  3. To install the OS you’d like to use in your container or VM, the command form for containers is
 lxc launch <image_server>:<image_name> <instance_name> 

or for VMs

lxc launch <image_server>:<image_name> <instance_name> --vm

For example:

lxc launch ubuntu:22.04 ubuntu-container

4. And now you’re ready to run commands. For a list of available commands and options, just run lxc

The LXD team maintains a youtube channel with a lot of helpful tutorials. From how to setup a home lab with a Raspberry Pi, to how to use Ceph, OVN or MAAS with LXD, to a deep dive in LXD clustering – there are a lot of useful hands-on videos. In addition, you can always get help and advice from the LXD community in our discussion forum


In this blog, we just cover the tip of the iceberg in terms of what LXD can do, and the ways you could use it. It’s a great tool for both beginners and advanced users, and it has all the features to develop, test and deploy your systems in a resource-efficient manner. It’s light-weight, intuitive and secure, and we encourage you to try it out for yourself. 

Open source is all about openness, learning and diverse perspectives. Open-source tools are developed in a collaborative way, making it easier to find solutions for the problem at hand. Follow along with the “Open source for beginners” blog series to learn more about other great open-source tools, and how they can help you in your learning journey or development career.

Ubuntu cloud

Ubuntu offers all the training, software infrastructure, tools, services and support you need for your public and private clouds.

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

Migrating from CentOS to Ubuntu: a guide for system administrators and DevOps

CentOS 7 is on track to reach its end-of-life (EoL) on June 30, 2024. Post this date, the CentOS Project will cease to provide updates or support, including...

Implementing an Android™ based cloud game streaming service with Anbox Cloud

Since the outset, Anbox Cloud was developed with a variety of use cases for running Android at scale. Cloud gaming, more specifically for casual games as...

ESXi Alternative: try open source LXD 

LXD is a modern, secure and robust ESXi alternative. With its intuitive CLI and web interface, users can easily get started and deploy and manage their...