Your submission was sent successfully! Close

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

Thank you for contacting our team. We will be in touch shortly.Close

  1. Blog
  2. Article

Gabriel Aguiar Noury
on 23 May 2022

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


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.

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.

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 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.

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. You may also read our previous posts on how to make a $HOME of your container, or how to expand your ROS development workflow with LXD including how to enable graphical applications!

Help improve this document in the forum.Join our Chapter 2 of Robot Makers to explore the funding landscape for robotics startups!

Related posts


Alex Murray
24 April 2024

What’s new in security for Ubuntu 24.04 LTS?

Confidential computing Security

We’re excited about the upcoming Ubuntu 24.04 LTS release, Noble Numbat. Like all Ubuntu releases, Ubuntu 24.04 LTS comes with 5 years of free security maintenance for the main repository. Support can be expanded for an extra 5 years, and to include the universe repository, via Ubuntu Pro.  Organisations looking to keep their systems secu ...


Henry Coggill
18 April 2024

DISA publishes STIG for Ubuntu 22.04 LTS

DISA STIG Article

Introduction DISA, the Defense Information Systems Agency, has published their Security Technical Implementation Guide (STIG) for Ubuntu 22.04 LTS. The STIG is free for the public to download from the DOD Cyber Exchange. Canonical has been working with DISA since we published Ubuntu 22.04 LTS to draft this STIG, and we are delighted that ...


Felicia Jia
16 April 2024

Canonical presence at Qualcomm DX Summit @Hannover Messe

Internet of Things Article

At the world’s leading industrial trade fair, companies from the mechanical engineering, electrical engineering and digital industries as well as the energy sector will come together to present solutions for a high-performance, but also sustainable industry at Hannover Messe. This year, Qualcomm brought its DX Summit to Hannover Messe, pu ...