A few hours ago, my colleague Darkcrizt wrote an article about the latest update distro box. He himself wrote a little while ago Another item in which he explained to us what it was, and a little bit about how to install it and the main commands to start taking advantage of its benefits. What we are going to do here is explain in more detail the installation and use processes of the software so that we can, for example, use a program that is only for Ubuntu in an Arch-based distribution.
Distrobox is a small program that creates images of distributions within other distributions, but they are not the same as virtual machines. Saving distances, is more like the Windows WSL, although Microsoft's subsystem for Linux does work through virtualization. It seems similar because we will do most of it from the terminal, just as WSL was at the beginning, and it also allows launching applications with GUI, available in the Windows subsystem from WSL2.
What Distrobox is really for
Some may be wondering what the point is of having one Linux inside another if almost everything that one Linux distro can do can be done in another. There is at least three reasons:
- Test in a throwaway environment. Distrobox can be used as a sandbox for testing and may be better than using a full virtual machine.
- Develop in different environments: Distrobox is useful for developers who want to use libraries and everything necessary from a distribution and do it on the same computer.
- Install apps not supported in our distro: Unfortunately, many developers care only for Debian/Ubuntu and Fedora users, and only upload their software in DEB or RPM packages. One reason to use Distrobox could be to install a DEB on our distro that does not support it without having to do much more. Does this explanation not convince you? I'll say it with another example: using normal Linux software on an immutable distribution, such as Ubuntu software on SteamOS (installed by default since SteamOS 3.5) without having to depend on Flathub.
How to install Distrobox
As we see in she is ready, distrobox is available in the official repositories of most distributions Linux, and its installation involves opening a terminal and writing sudo <nombre del gestor de paquetes de turno> <comando de instalación> distrobox
. For example, in Ubuntu and derivatives you have to write "sudo apt install distrobox" and in Arch "sudo pacman -S distrobox", all without the quotes. It's worth installing too docker, deception or both. They are the programs that will make the magic of containers possible. If you choose one, all the documentation I've found recommends Podman more.
The official website also describes how to install with alternative methods. What is explained at this point is similar to what Darkcrizt published in the second link that we included at the beginning of this article, perhaps updated. I would recommend using the official repositories whenever possible, that's what they are for.
How to install an image from another distro
To get started, we can open a terminal window and type:
distrobox create
It will show us a message that a Fedora image cannot be found – at least when this article was written – and we have the option of creating it or not. If we press the "Y" key (yes), it will create it for us after downloading the image, which may take a while. At the end of the installation we will see a message that tells us how to execute it:
It will be executed with the following, where the name of the "box" also appears above, at the point where you are creating it and when you have already achieved it:
distrobox enter my-distrobox
With the previous command the necessary packages for the box will finish downloading, so you have to wait again.
In the previous image you have to look at the detail of the prompt, that is, the message that appears by default and that invites us to enter commands. In the screenshot we see that it says my username followed by "my-distrobox", which is the box we just created and indicates that we are in it. If we want to check it, we can install neofetch, but we can do it with:
cat / etc / os-release
Installing and running programs
Now that we have the distro installed and running, we are going to do a test. software installation. Since what we have in the example is Fedora, we are going to perform the installation with DNF, and the program chosen will be Firefox because its information makes it easy to demonstrate which system it is running on. The command would be:
sudo dnf install firefox
As those of you who know Fedora can see, what it shows is the typical information of the DNF package manager. But if that is not enough proof, now we launch the browser by typing "firefox" without the quotes in the same terminal. Then we go to the Help/About Firefox section and we will see something like the following:
Creating custom Distrobox images
By default, it is prepared to install Fedora, and this is explained in the information we found at the beginning. But we can create images from a list of options which is available in the Distrobox compatibility information (link). In the following example we are going to install an Ubuntu image, but giving it a custom name. To do this we will use the following command:
distrobox create -n ubuntubox --image ubuntu:22.04
With the previous command we have asked you to "create an image with the name 'ubuntubox' from the Ubuntu 22.04 image." You won't find it, so It will ask us if we want to create it and we must say yes. As when creating the Fedora image, we must wait for it to create it and then download everything necessary to run it. When we see the prompt from ubuntubox, we will already be inside Ubuntu 22.04.
If we want to see a list with the installed boxes, we will write – from outside no box -:
distrobox list
Using applications from the main menu
If we want use applications in the main menu or access them from the host system, we will enter a box and write something like this:
distrobox-export --app firefox
We will see a message confirming that the app is available and it will be so. The one on the box has his name in parentheses.
We will undo the export with:
distrobox-export --app firefox --delete
Delete a Distrobox box
FOR delete a box, this one has to be stopped. This will be achieved by writing, from the host system, first distrobox stop nombre-de-la-caja
and then distrobox rm nombre-de-la-caja
. In both cases we must accept the messages it shows us. The box and all its contents will disappear from distrobox, but more steps are required to completely remove the container.
- In the terminal, we write
podman images
. - We write down the ID of the image we want to delete.
- Lastly, we write
podman rmi id-de-la-imagen
, replacing the last string with that of the image to be deleted.
If there are any shortcuts left in the applications menu, although it should not happen, they can be deleted manually from the folder ~ / .local / share / applications /. To avoid this, it is worth undoing the exports before deleting the box.
Some interesting data
- The kernel used on the boxes is the same as the default host system.
- If we want to leave, we have to enter the word
exit
. - A box can be accessed directly from the applications menu. A .desktop file is created for this.
I hope that with this guide it is now clear what Distrobox is, what it is for and how it is used.