Distrobox is a nifty tool that allows you to create and manage containers on your favorite Linux distribution using either Docker or Podman. The launched container becomes highly integrated with the host system and this allows sharing of the user’s HOME directory along with external storage, USB devices, and graphical applications.
Distrobox is based on an OCI image and implements similar concepts to those of ToolBox which is built on top of podman and OCI standard container technologies.
In this guide, we will demonstrate how to install DistroBox to run any Linux distribution inside your Linux terminal. For this guide, we are running Fedora 34.
Prerequisites
Before you proceed, ensure you have the following:
- Minimum podman version: 2.1.0 or docker version: 18.06.1.
Step 1: Install DistroBox on Linux System
Installing DistroBox is a piece of cake. Simply run the following curl command which downloads and run the installation script.
$ curl https://raw.githubusercontent.com/89luca89/distrobox/main/install | sudo sh
In Fedora, DistroBox is available from the Copr repository. So, enable the Copr repository on Fedora.
$ sudo dnf copr enable alciregi/distrobox
Once the Copr repository has been added, use the DNF package manager to install Distrobox.
$ sudo dnf install distrobox
Step 2: Create a Container from an Image
With Distrobox installed, we can now get started with creating and running containers. To pull an image and run a container from the image, use the distrobox-create command as follows.
$ distrobox-create --name container-name --image os-image:version
In this example, we are creating a container called debian10-distrobox from the Debian 10 image.
$ distrobox-create --name debian10-distrobox --image debian:10
The command pulls the Debian 10 image from Docker Hub and creates a container called debian10-distrobox.
To get a complete list of operating systems and versions supported by Distrobox containers, visit the Distrobox Project page.
To list containers created with Distrobox, run:
$ distrobox-list
Step 3: Accessing a Distrobox Container
To access the shell of the newly created Linux container, use the distrobox-enter command as follows:
$ distrobox-enter --name container-name
For example, to access our container, we will run the command:
$ distrobox-enter --name debian10-distrobox
From here, you can run commands inside the container. For example, the following command checks the OS version.
$ cat /etc/os-release
You can also install applications. Here, we are installing the Neofetch utility tool.
$ sudo apt install neofetch
Once Neofetch is installed, launch it as follows.
Step 4: Run Commands On Distrobox Container
You can directly run the commands on a Distrobox container instead of accessing the shell using the syntax shown.
$ distrobox-enter --name container-name -- command
In the following commands, we are displaying the uptime of the container and updating the package lists respectively.
$ distrobox-enter --name debian10-distrobox -- uptime $ distrobox-enter --name debian10-distrobox -- sudo apt update
Step 5: Exporting Applications from Container to Host
In case you have an application inside the Distrobox container that you would like to port to the host system, you can do so using the distrobox-export command. Bur first, access the container’s shell.
$ distrobox-enter --name container-name
Here, we are going to install Flameshot which is a free and open-source cross-platform tool for taking screenshots.
$ sudo apt install flameshot
To export the application to Fedora, we will run the command:
$ distrobox-export --app flameshot
To exit the container, run:
$ logout
Now back to the Fedora host system. To confirm the existence of the application, we will run the search for the application using the Application menu as follows.
Step 6: Cloning a Distrobox Container
Sometimes, you might need to create a duplicate or a clone of a container image. To achieve this, first, stop the running container using the podman command
$ podman stop container_ID
To get the container ID, run the podman ps command to list currently running containers.
$ podman ps
Once the container is stopped, you can create a duplicate as follows. In this example, we are duplicating the debian10-distrobox distrobox to a clone called debian-10-clone.
$ distrobox-create --name debian-10-clone --clone debian10-distrobox
To confirm that the clone has been created, yet again, list the Distrobox containers as shown.
$ distrobox-list
Step 7: Managing Distroboxes in Fedora
In this last section, we will briefly go over how to manage containers using podman.
To list all active containers, run:
$ podman ps
To list all running containers both active and those that have exited, run:
$ podman ps -a
To stop a container, run the command:
$ podman stop container_ID
To remove a container, be sure to stop it first and then remove it.
$ podman stop container_ID $ podman rm container_ID
Conclusion
Distrobox is a handy utility that allows forward and backward compatibility with software applications and also enables you to try out various Linux distributions in form of containers without requiring sudo privileges.
Give this a try to run a browser in the container. Seems to work great except you can’t play any videos in the browser because the distrobox container won’t export sound to the host sound card.
I’ll start researching to see if there’s a way around this, but probably won’t be able to run any apps that need access to the host hardware I guess.
Hi,
Thanks a lot, great article…
Thanks, Ravi for the procedures depicted here!
Except for a couple of individual issues, the Distrobox procedure worked just fine.
Regards
I want to update my old Fedora to the latest version (above Fedora 34).
I’m looking for detailed instructions. Please help
@Suresh,
That’s not possible in any way, you have to do a fresh Fedora install.
@Ravi
Thanks for the response. Much appreciated.
Could you please describe more on it, like why is it not possible in any way!?
Will, it not work from step by step upgrade like 17 to 18 and from 18 to next stable version upgrade until we reach to latest version!?
Request to describe in detail, for good understanding.
@Suresh,
Yes, it will work like upgrading from Fedora 17 to 18, 18-19, and so on until you reach to the latest, but the time it will take, I have no idea.
So I suggest, better to have a fresh Fedora install..
@Ravi,
Thank you