How to use Distrobox for multiple local development environments?

How to Distrobox to create many different development environments.

How to use Distrobox for multiple local development environments?
Photo by Dan Cristian Pădureț / Unsplash

So in the past I've written a couple of posts about using Toolbox containers as my dev environment. While Toolbox has its advantages and flexibility, there are still some limitations that need to be worked around. One such limitation I've written about before.

A better solution comes in the form of Distrobox. It's the same concept as Toolbox but a little more flexible. What makes distrobox different, is that fact that you can use different distributions, and create shortcuts on the host for the applications installed inside the container.

A great distribution for development is Arch Linux because it is a rolling release which is updated very frequently. Arch notoriously difficult for beginners to install, but Distrobox makes it easy. You can start using Arch with just one command:

distrobox create -i archlinux

Once created, enter the container using:

distrobox enter archlinux

Now you have full access to an Arch environment. The advantage of this being a container is that, even if the container breaks because of an update, or any other reason, it simply be replaced with a new container. Also, if multiple development environments are required with different versions of the same tools, using a container makes that easy and flexible.

Within this container, you can install all the development tools you need. These include graphical tools like VS Code. Then export the application to create a shortcut on the host OS. Execute the following commands within the container

sudo pacman -S code
distrobox-export --app code

These command will install and create a shortcut for VS Code on the host OS. The advantage of installing everything in the container is that the build tools are natively accessible. To get the VS Code Flatpak to work, you had to alter the environment using Flatseal, install Podman extension, and enable Podman socket. VS Code installed directly in Distrobox has native access to all the build tools and language servers install on the container.

Distrobox supports many different host operating systems. Try out for yourself and happy hacking :)