Distrobox is a straightforward command-line tool that enables you to run any Linux distribution directly on your computer. Unlike VirtualBox, which requires running a full virtual machine, Distrobox creates “overlays” that let you run programs from different Linux distros seamlessly on your current system. In this guide, we’ll dive into the inner workings of Distrobox and walk you through the steps to install and use it.
Content
- Why Use Distrobox to Manage Multiple Linux Distros
- Installing and Testing Distrobox
- Deploying Your First Overlay Distro
- Installing and Running Packages on Distrobox
- Exporting an Overlay Program to the Host System
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.
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.
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
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.
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.
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.
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
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.
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.
Test your new package by running it once inside the overlay and another outside it.
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
Good to know: using a different package manager? Check out our handy package manager cheatsheet for different Linuxux 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.
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.
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.