You don’t need to dual-boot or switch between distros. Distrobox lets you install and run any Linux distribution inside a virtual container or “box.” You can access that distro’s package manager and install apps (GUI or CLI) that run within your native distros desktop space.
How I stopped distro hopping
A few years ago, I suffered from a kind of “shiny object” syndrome for Linux distributions. Instead of installing and setting up an OS and using it daily for work, I kept switching to every new distro I came across. I later found out it’s actually fairly common among Linux hobbyists. So common, in fact, that there’s a name for it. It’s called “distro hopping.”
The weird part is that most of the Linux distros I hopped to and from were all based on Debian. When I eventually decided to settle on one setup, I realized that I was chasing aesthetics and customization with my distro hopping hobby. It was an interesting realization because the community taught me that I could customize any distro to look like any other. I could just swap out the desktop environment, the lock screen, the bootloader, and everything in between.
What I can’t hot swap is the default package manager and how the system handles updates. Debian and Debian-based systems, for example, use the APT package manager. The official repos for this package manager have far fewer packages than the official Arch Linux repos. The apt packages are typically not up-to-date either. With Arch and the Arch User Wiki (AUR) in particular, you get access to the latest versions of twice as many packages. I also favor Arch’s pacman package manager because it’s much faster and has better features.
Lucas Gouveia/How-To Geek
So if I could find a way to access my favorite package managers on any Linux system, I would have no reason to distro hop. That’s exactly what I did.
Running Linux boxes inside a Linux system
Docker and Podman are container engines which allow you to run services and applications inside containers or boxes. Instead of installing an app on your machine, you can run it inside an isolated sandbox which contains the app needs (libraries, dependencies, configs, everything). That’s what Docker or Podman do.
It takes an image (which acts like a template or a recipe) and spins up a container based on it. The image can be anything. It doesn’t have to be an app or a service. It can be an entire Linux operating system.
Distrobox is a Linux designed expressly for this job. It uses Docker or Podman to spin up Linux boxes. This is different from a virtual machine because Distrobox is not emulating hardware or running a separate kernel. It’s working off the native host kernel, so it gives you near-native performance.
All you need to do is open a terminal, enter a single command to create a new Linux box, and enter it. You can run apps (GUI or CLI) directly from the terminal using the display sockets of your host desktop. Graphical apps will pop up in a separate window on your desktop.
You can use those apps normally just like you would native apps because the Linux container (by default) has access to your Home directory. So all your files are accessible within the Distrobox container.
Setting up Distrobox
You’ll need to install Docker or Podman before you can run Distrobox. If you already have Docker or Podman installed, you can skip this step. I use Docker regularly, so I’ll show you how to set up Distrobox with Docker. You can use Podman, if you like.
On Arch systems, you can install Docker and Docker Compose with the following command:
sudo pacman -S docker
On Debian and Fedora systems, try this:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
These commands run an official Bash script from Docker that conveniently installs and starts the Docker engine.
Let’s test if Docker is working properly.
sudo docker run hello-world
If everything goes well, you should see a message confirming that Docker is running as expected. Now let’s get Distrobox.
On Debian and Ubuntu systems, run this command to install Distrobox.
sudo apt install distrobox
Arch and Fedora have Distrobox in the official repos.
Creating a Linux box and running apps
To create a new Distrobox container, you just need to know the name of the distro and the version number. For rolling distros, you can just type “latest” next to the distro’s name. For example, you can create a new Arch Linux box with the following command.
distrobox create --name archbox --image archlinux:latest
You can give the container any name next to the --name flag. Remember that name because you’ll need it to enter the container.
distrobox enter archbox
You can now install apps from the official pacman repos or from the Arch User Repository and run them within this same terminal.
To create an Ubuntu box, you can run a command like this.
distrobox create --name my-ubuntu --image ubuntu:22.04
This command will get you a Fedora Box.
distrobox create --name my-fedora --image fedora:latest
Type distrobox stop container_name, to stop a distro container. You can delete a box with the distrobox rm container_name command. You can stop a container with distrobox stop container_name. Also, you can get a list of all installed boxes with distrobox list.
There’s no need to install a new Linux operating system just to access its repos and package manager. Distrobox makes it incredibly simple to create as many Linux boxes as you need. You can even run multiple Linux distros side-by-side.
