What is Distrobox?
Distrobox is a piece of software that will allow you to run containerized terminal and graphical-based applications from many Linux distributions on many other Linux distributions.
- You can run applications from Arch’s AUR on openSUSE.
- You can run applications from .deb files that are only available for Ubuntu on Fedora.
- You can run applications from an old version of Debian on a current Manjaro system without fighting with dependency hell.
- You can even run entire desktop environments on operating systems that never supported them.
Because the applications are running in containers, they do not interact with the base system’s package management system.
How have I been using Distrobox?
When I started using Distrobox, I started wondering what are the limits of what I could do with this system? I was able to install my favorite Usenet newsreader, Knode from Debian 8, and openSUSE on whatever system I wanted. It opened whole new doors for experimenting with software that may be long forgotten.
Could I run a simple windows manager like i3, Sway, or IceWM in Distrobox? It took some trial and error, but yes I could.
Now, with that said, we are working with containers. When you run an application in Distrobox, it mainly sees your actual home directory. Outside of your home directory, it sees the container’s filesystem. If you save something to your home directory, it gets saved to your real home directory and you can open it up like you could normally. If you save something to /usr/local/ or any other directory outside of your home directory, it will only be saved in the container and not to your actual base filesystem.
Let’s take that one step further. Let’s say I MATE as my base openSUSE desktop environment and I have 3 containers with other desktop environments. I have an Arch Distrobox container with i3, I have a Fedora Distrobox container with XFCE, and I have a Debian Distrobox container with IceWM. I can run applications from any of these containers on the base openSUSE MATE installation. However, I can’t run applications from Fedora on Debian or from Debian on Arch, etc. That’s the limitation with running these containers.
How do I run Windows Managers and Desktop Environments?
As I said earlier, this took a fair amount of trial and error to get this right, and I’m sure there are lots of things that could make this easier.
For instruction on actually installing Distrobox, check out the installation instruction page. This will vary depending on your Linux distro.
Let’s begin by installing the IceWM window manager in a Distrobox container. We’ll start with an Ubuntu container:
Create and enter the container:
distrobox-create ubuntu --image docker.io/library/ubuntu
Now that we’re in our new Ubuntu container, let’s install IceWM. This where things start getting difficult. Even if you’re a pro at installing packages in Ubuntu or Debian, it can be really difficult to understand what exactly you need to install. My suggestion is to start with the wiki for your distro of choice for the window manager to desktop environment that you’re trying to install.
According to the Ubuntu Wiki for IceWM, we need to install package for the base installation:
sudo apt-get install icewm
This will take some time to complete depending on your hardware.
Next, we need to see how to start IceWM. Part of the IceWM installation is the creation of /usr/share/xsessions/icewm-session.desktop. This is what tells your display manager how to start IceWM. Inside of this file is a line that says:
This is the command that we will need to start IceWM. Let’s copy that file to our home directory and then use it again in a minute:
cp /usr/share/xsessions/icewm-session.desktop ~/
We can exit out of the container for now and work in the base OS:
The way we run applications from inside of the container in our base OS is with the distrobox-enter command:
/usr/bin/distrobox-enter -T -n [container] -- "[app]"
This command would run the [app] application from the [container]. However, you can’t use this command in a desktop file like the icewm-session.desktop files that we saved earlier, so we need to make one more step to create a bash script to do this for is:
/usr/bin/distrobox-enter -T -n ubuntu -- "icewm-session"
xhost +SI:localuser:$USER will allow graphical applications to be run from containers only for the current user. Without this, the icewm-session application could not start.
Save that in /usr/local/bin or some other location in your path and make it executable with chmod.
sudo chmod +x /usr/local/bin/icewm
In the icewm-session.desktop file that we saved earlier, we can change
Exec=/usr/local/bin/icewm and then save it to the /usr/share/xsessions on our base OS:
sudo cp ~/icewm-session.desktop /usr/share/xsessions/icewm-session.desktop
Now when log out, you should see IceWM as an option in your display manager. When you log in with it, you will be in the Ubuntu container. Even if you are not running Ubuntu as your base OS, you will be like you did.
Distrobox is an amazing tool and I plan on using it as much as I can.
IceWM is probably not many people’s desktop of choice, but it is small, light on resources, and easy to get going. Take this as a sample of how you can use Distrobox to be so much more than just running applications. You can try our whole new Linux distros without fussing with VMs or changing your current distro.