How to Run Any Program from Any Linux Distro with Distrobox

A photograph of a laptop on top of a table.

Distrobox is a simple CLI tool that can boot up any Linux distro inside your computer. Unlike VirtualBox, Distrobox creates “overlays” that allow you to run any program from different Linux distros on top of your current system. Here, let’s check out what makes Distrobox tick and how you can install and use it.

Why Use Distrobox to Manage Multiple Linux Distros

The biggest selling point of Distrobox is that it runs guests on top of the host instead of using an isolated instance. Compared to a traditional VM, this allows you to seamlessly access your host’s home directory, its external devices, and even its display server.

A screenshot showing Ubuntu running two different distros inside it.

This level of tight integration between the guest and the host allows you to do a handful of unique things with Distrobox. For instance, you can install a GUI application on an Ubuntu guest and export its shortcut to your host system’s desktop. As a technical writer, I find this feature useful when testing and comparing different apps.

A screenshot showing two versions of Vim running on two Distrobox instances.

Lastly, Distrobox is also incredibly lightweight. This makes it ideal for lower-end systems that don’t have the resources to run multiple VMs. In my experience, running Ubuntu and Fedora guests for around six hours only consumed around 900 MB of my host’s overall RAM.

Installing and Testing Distrobox

At its core, Distrobox works by taking advantage of container daemons such as Docker and Podman to manage its distros. Because of that, the first step in deploying Distrobox is to install Docker on your machine.

Confirm that the Docker daemon is running on your system by checking its version:

docker --version

Add your current user to the docker system group:

sudo adduser $USER docker
A terminal showing the process of adding the current user to the Docker group.

Download and install Distrobox using your system’s package manager:

sudo apt install distrobox

Make sure that you’ve properly installed Distrobox by running it with the -h flag.

A terminal showing Distrobox help screen.

Deploying Your First Overlay Distro

With Distrobox up and running, you can now install your first Linux distro overlay. For this, the developers provide a Fedora 39 OCI image as its default install media.

Start by running Distrobox with the create subcommand followed by the name and the hostname that you want for your new overlay:

distrobox create --name YOUR-OVERLAY-NAME-HERE --hostname YOUR-CONTAINER-NAME-HERE

Type “y,” then press Enter to pull and deploy your new overlay distro.

A terminal showing the confirmation prompt for creating a new Distrobox instance.

Note: depending on your system’s hardware, it might take between 5 to 10 minutes to fully install the guest system in Distrobox.

Once done, run the following command to boot up and load your new overlay distro:

distrobox enter YOUR-OVERLAY-NAME-HERE

Confirm that you’re now inside the overlay system by looking at the hostname on your terminal prompt.

A terminal highlighting the different system hostname inside the Distrobox instance.

To close an overlay session, press Ctrl + D on the guest terminal, then run distrobox stop followed by the name of your overlay.

On a side note: explore the power of Fedora and Red Hat Enterprise Linux by looking at our comprehensive guide on the DNF package manager.

Running a custom Linux image on Distrobox

Aside from Fedora 39, it’s possible to run other OCI-compatible Linux distro inside Distrobox, for example, Arch Linux.

To install a custom Linux distro, run the create subcommand with the -i flag followed by a link to an OCI-compatible image. In my case, I’m going to use the Arch Linux Toolbx image from Quay.io as the base for my overlay:

distrobox create --name arch-linux --hostname mte-archlinux-container --image quay.io/toolbx/arch-toolbox:latest
A terminal showing the process of creating an Arch Linux Docker container.

Note: you can find a list of compatible distros and their download links on the developer’s Github page.

After it’s done, boot up the overlay and go inside your new Arch Linux system:

distrobox enter arch-linux

Just like with Fedora, confirm that you’re now running Arch Linux by checking your terminal’s hostname.

A terminal showing the process of entering a newly spawned Distrobox instance.

Installing and Running Packages on Distrobox

One of the benefits of Distrobox’s tight integration is that guest systems behave as if they’re native to the host machine. Because of that, installing and running any program in Distrobox is similar to a regular Linux install.

To install a package on a Distrobox guest, first make sure that you’re currently inside your overlay distro:

distrobox enter arch-linux

Note: you can list the available overlays on your system by running distrobox ls.

Use the package manager of your guest distro to install the program that you need. In this case, I will run sudo pacman -S neofetch to install neofetch on my Arch Linux guest system.

A terminal showing the pacman package manager running inside a Distrobox instance.

Test your new package by running it once inside the overlay and another outside it.

A terminal showing the program isolation between the Arch Linux Distrobox and the Ubuntu host system.

You can also install a program from outside the Distrobox overlay. For that, use the enter subcommand followed by the -- operator:

distrobox enter --name arch-linux -- sudo pacman -s neofetch

This feature extends to running programs outside your guest system. For example, the following command will run neofetch on my Arch Linux guest and display its output in my Ubuntu host system:

distrobox enter --name arch-linux -- neofetch
A terminal showing the neofetch program inside the Arch Linux instance running on the Ubuntu host.

Good to know: using a different package manager? Check out our handy package manager cheatsheet for different Linux distros.

Exporting an Overlay Program to the Host System

While the -- operator is great for simple one-off tasks, it’s also possible to create Distrobox “profiles” that allow you to run any guest programs directly from your host Linux machine. This is helpful if you want to have constant access to a program inside your Distrobox guest system.

To export to your host machine, first go inside the system where you’ve installed your program:

distrobox enter arch-linux

Make sure that your application is working properly from inside the container. In my case, I want to export my Emacs install inside Arch Linux.

A screenshot showing the Emacs GUI client running inside the Arch Linux Distrobox instance.

Run distrobox-export with the --app flag followed by the name of the program that you want to export:

distrobox-export --app emacs

Test your newly exported app by going to your host system’s application launcher and clicking the program icon.

A screenshot showing the Ubuntu application launcher showing the Emacs GUI client.

Installing and running guest OSes with Distrobox is just one example of what you can do with Docker and container technology. Take a deep dive into how this program works by checking out our primer on running and managing Docker containers.

Image credit: Kari Shea via Unsplash. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red Avatar