by Nishanth Entoor
Share
by Nishanth Entoor
What is a Distrobox?
Distrobox is a wrapper around podman, docker or lilipod to manage Linux containers. It allows the containers to tightly integrate with the host system, and it also allows sharing of user’s HOME directory, external storage and USB devices, audio, and graphical applications.
It is a great way to integrate containerized apps as native apps irrespective of the Linux distribution on which the containerized app is running. This makes it easy to run and test applications on various distributions which would be extremely helpful for those building packages for different distributions or even setting up a test environment with the same distribution as the host’s.
It allows us to natively run software that is not available for the host distribution or even a different version of software that is already installed on the host machine.
Container Manager
Since Distrobox needs to create and start containers, it uses one of the three container managers, namely Podman, Docker, and Lilipod.
Lilipod is a very simple container and image manager from the developers of Distrobox. It is used as a fallback in case there is no container manager found, or it is not possible to install one. It is already shipped with Distrobox binaries.
While choosing the container manager, it is recommended to go with Podman instead of docker since Podman runs rootless containers by default, which is a better option from a security standpoint.
Getting Started with Distrobox
Installation
Before installing Distrobox, we must have either Podman or Docker. As Podman is the recommended container manager, we will choose it.
As Distrobox is only available in the apt repository of Ubunutu 22.10 and later, if you are using the last Ubuntu LTS version 22.04 and before or any distribution based on it, you need to add the PPA repository. These steps should be similar with other distributions and package managers as well.
- Install Podman.
sudo apt install podman
- If you are using Ubuntu 22.04 and before, add the PPA repository for distrobox.
sudo add-apt-repository ppa:michel-slm/distrobox
sudo apt update
- Install Distrobox.
sudo apt install distrobox
Distrobox In Action
-
- The most exciting feature of Distrobox is its ability to export an app in the container to host operating system that can be launched from the app launcher. We can do that by running the distrobox-export command in the container. Let us run the below command in the Ubuntu container.Once Distrobox is successfully installed, we can start creating containers.
- Create a new container by providing a name using the –name flag. If no name is provided it chooses a random name. The base image for the container can be set by using the –image flag and the default is Fedora. In the below command we do not set the image flag.
distrobox create –name ut-test
- Use the command at the end of the create command output to enter the container. Once the container starts successfully, it enters the container’s shell. You can see that with the change in the hostname from ubuntu-vm to ut-test.
distrobox enter ut-test
- Let us check the os-release file to make sure it is indeed using Fedora.
cat /etc/os-release
- Now, let us try to install kate, a GUI text editor in the Fedora container and see if we can use it.
sudo dnf install kate
- Once the installation is complete, we can start the text editor by using the command kate.
- We can now see that it is running like a native application.
- As mentioned previously, if we want to change the container image, we can use the —image flag.
distrobox create –name ubuntu-distrobox –image ubuntu:22.04
- Let us run the above command to start an Ubuntu container, enter the container as we did earlier with ut-test container and install kate using the below command and then start it the same way we did before.
sudo apt install kate
- When the application starts, if we go and check its version, it would be different from the version installed on the Fedora container. Also, if you check the top of the window where it shows the name of the application, we will see that it is running on the ubuntu container.
- The most exciting feature of Distrobox is its ability to export an app in the container to host operating system that can be launched from the app launcher. We can do that by running the distrobox-export command in the container. Let us run the below command in the Ubuntu container.
distrobox-export –app kate
- Once it is successfully exported, we should be able to launch it from the host machine’s app launcher.
- The most exciting feature of Distrobox is its ability to export an app in the container to host operating system that can be launched from the app launcher. We can do that by running the distrobox-export command in the container. Let us run the below command in the Ubuntu container.Once Distrobox is successfully installed, we can start creating containers.
Our Conclusion about Distrobox
We have seen that Distrobox allows us to seamlessly use applications running on containers like native apps. It can even be used as a full-fledged operating system.
It gives us the ability to run any application as long as it is available for any one of the Linux distributions without worrying about whether it is available for our host distribution.
It can also be used to set up test environments, be it having the possibility to test the application across different distributions or separating the test instance from the host and helping to keep the host machine clean.
This is one of the (relatively) new and exciting tools we came across in the recent times and we can’t wait to see its application areas in the future.