---
title: Install ROS 2 Humble in Ubuntu 20.04 or 18.04 using LXD containers
description: Discover how you can install ROS 2 Humble and test compatibility with
  your current Ubuntu environment with LXD containers.
url: https://canonical.com/blog/install-ros-2-humble-in-ubuntu-20-04-or-18-04-using-lxd-containers?format=md
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[Gabriel Aguiar Noury](https://canonical.com/blog/author/g-aguiar-noury "More about Gabriel Aguiar Noury")

23 May 2022

# Install ROS 2 Humble in Ubuntu 20.04 or 18.04 using LXD containers

[robotics](https://canonical.com/blog/tag/robotics)
[ROS2](https://canonical.com/blog/tag/ros2)
[Ubuntu](https://canonical.com/blog/tag/ubuntu)

---

Share the article
> Please note that this blog post has out technical information that may no longer be correct. For latest updated documentation about robotics in Canonical please visit <https://ubuntu.com/robotics/docs>.

We welcome the new release of ROS 2 Humble which targets the recently released Ubuntu 22.04. If you want to install it now, please visit the [ROS 2 Humble documentation](https://docs.ros.org/en/humble/Installation/Alternatives/Ubuntu-Development-Setup.html).

But if you want to install ROS 2 Humble and test compatibility, keeping your current Ubuntu (20.04, 18.04,…) environment stable until you know you are ready to upgrade, you can dive into LXD containers.

In this blog post, we’ll create an LXD container running 22.04, that will allow us to easily install ROS 2 Humble at the convenience of our current Ubuntu station. So follow this blog from [Ubuntu’s robotics team](https://ubuntu.com/robotics).

## Initial configuration

If this is the first time that you are using LXD, let’s start by installing it:

```
sudo snap install lxd
```

Before you can create an instance, you need to configure LXD.

Let’s create a minimal setup with default options by adding the –minimal flag. If you want to learn more about the different configuration options, see  [Interactive setup](https://linuxcontainers.org/lxd/getting-started-cli/#interactive-setup-options) for an explanation.

```
sudo lxd init --minimal
```

## Launch a container

To launch a new container, you just need the following command:

```
lxc launch <image_server>:<image_name> <instance_name>
```

Without root access, users must be added to the lxd group. To do so, run `sudo usermod -a -G lxd $USER` and reboot the computer.

For installing ROS 2 Humble we need to launch a container with an Ubuntu 22.04 image from the images server using the instance name ubuntu-container, enter the following command:

```
lxc launch images:ubuntu/22.04 ubuntu-container
```

Once created, the container will be running. To see all the created LXD containers, run reboot `lxc list`

## Get shell access

Let’s start a shell in the created container to run commands directly. Enter the following command:

```
lxc exec ubuntu-container -- /bin/bash
```

By default, you are logged in as the root user. If you want to log in as a different user, enter the following command:

```
lxc exec <instance_name> -- su --login <user_name>
```

## Install ROS 2 Humble

Now, inside the shell of the created container, let’s install ROS 2 Humble by following the [installation instructions](https://docs.ros.org/en/humble/Installation/Alternatives/Ubuntu-Development-Setup.html).

## Change the name of your container and more

Once you have installed ROS 2 Humble you are ready to start exploring this new ROS distribution. But you can also change the name of your container.

To do so, first, stop the container to rename it

```
lxc stop ubuntu-container
```

Then just run the command:

```
lxc move {old-lxc-name} {new-lxc-name}
```

So let’s rename it to ros-humble

```
lxc move ubuntu-container ros-humble
```

LXD provides a number of handy commands for working with containers. For instance, we can clone a container by simply using the lxc copy command:

```
lxc copy ros-humble ros-humble-2
```

When work with the container is complete, simply remove it:

```
lxc delete ros-humble-2
```

If you want to learn more about LXD and how to tweak it to your workflow, [visit the documentation](https://linuxcontainers.org/lxd/getting-started-cli/#interactive-setup-options). You may also read our previous posts on how to make a [$HOME of your container](https://ubuntu.com/blog/feeling-at-home-in-a-lxd-container), or how to expand your [ROS development workflow with LXD](https://ubuntu.com/blog/ros-development-with-lxd) including how to enable graphical applications!

Help improve [this document in the forum.](https://discourse.ubuntu.com/)Join our [Chapter 2 of Robot Makers](https://ubuntu.com/engage/robotmakers-webinar-akara) to explore the funding landscape for robotics startups!

[Get in touch

Interested in running Ubuntu in your organization?](https://ubuntu.com/about/contact-us/form)

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

By submitting this form, I confirm that I have read and agree to [Canonical's Privacy Policy](https://canonical.com/legal/dataprivacy).

Sign up

## Share on

---

## Related posts

[### Arduino® VENTUNO™ Q is available for pre-order with Ubuntu pre-installed](https://canonical.com/blog/arduino-ventuno-q-is-available-for-pre-order-with-ubuntu-pre-installed)

London, UK – August 25, 2026 – Following our initial collaboration announcement in March 2026, Canonical and Arduino (a subsidiary of Qualcomm Technologies, Inc.) are excited...

[Canonical](https://canonical.com/blog/author/canonical)

25 August 2026

[### Canonical becomes Gold Sponsor of Trifecta Tech Foundation](https://canonical.com/blog/canonical-becomes-gold-sponsor-of-trifecta-tech-foundation)

Canonical is pleased to announce it is now a Gold Sponsor of the Trifecta Tech Foundation, a non-profit that creates open source building blocks for critical infrastructure...

[Canonical](https://canonical.com/blog/author/canonical)

30 June 2026

[### Ubuntu Summit 26.04: connected by open source](https://canonical.com/blog/ubuntu-summit-26-04-connected-by-open-source)

What an incredible experience! Ubuntu Summit 26.04 has officially drawn to a close, but the energy from our global community is still buzzing – in the comments section, on...

[ilvipero](https://canonical.com/blog/author/ilvipero)

22 June 2026

[### A decade of Ubuntu on IBM Z and IBM LinuxONE](https://canonical.com/blog/a-decade-of-ubuntu-on-ibm-z-and-ibm-linuxone)

This year we celebrate a decade of Ubuntu Server support on the s390x architecture: marking a long-standing collaboration between Canonical and IBM that began at LinuxCon 2015....

[Pedro Lazzarotto](https://canonical.com/blog/author/pedro-lazzarotto)

12 June 2026
