Hey there, tech enthusiasts! Ready to embark on a journey into the world of Distrobox? Strap in as we explore the ins and outs of this nifty tool. But first things first…
What’s the deal with Distrobox?
Ever wished you could test out different Linux distributions without committing to full-blown installations? Well, Distrobox grants you that wish! It’s like having a box full of distros ready to play with, without the hassle of setting up multiple virtual machines or partitioning your hard drive.
Wrangling with Podman
Now, you might wonder, “What’s Podman got to do with all this?” Simply put, Podman is our trusty sidekick in this adventure. It helps us manage containers effortlessly, making our Distrobox experience smoother than a fresh jar of peanut butter.
Let’s get cooking: Installing distrobox and podman
Enough chit-chat, let’s roll up our sleeves and get down to business. Installing Distrobox and Podman is as easy as pie. Just fire up your terminal and follow along:
$ sudo apt-get install distrobox podman # For Debian/Ubuntu
$ sudo yum install distrobox podman # For CentOS/RHEL
$ sudo dnf install distrobox podman # For Fedora
For other distros, check out the official documentation for installation instructions. Once that’s done, you’re all set to dive into the container wonderland!
On my Arch install, I’d do this a little differently via a shell script that I have:
#!/usr/bin/env zshif[["$1"=="clean"||"$1"=="cleanup"||"$1"=="--clean"||"$1"=="-c"||"$1"=="--cleanup"]];thensudo rm -rf~/.config/containers/ ~/.local/share/containers/ ~/.cache/containers/ ~/.Podman/ ~/.local/share/icons/distrobox /var/lib/containers /var/tmp/podman-static/1000/containers ~/.local/share/podman-staticecho"Cleaned up container data"else# stuff is stored in ~/.config/containers and ~/.local/share/containersmkdir -p~/.Podman/bin/mkdir -p~/.home/ # the home directorysudo chown -R stig:stig /home/stig/.home/ # fix permission issues inside containers# Install distrobox and bundled podman# Distroboxcurl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install|sh -s -- --prefix ~/.Podmancurl -s https://raw.githubusercontent.com/89luca89/distrobox/main/distrobox --output~/.Podman/bin/distrobox# Podman# curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/extras/install-podman | sh -s -- --prefix ~/.Podmancurl -fsSL https://github.com/89luca89/podman-launcher/releases/latest/download/podman-launcher-amd64 -o~/.Podman/bin/podmancurl -fsSL https://github.com/89luca89/lilipod/releases/latest/download/lilipod-linux-amd64 -o~/.Podman/bin/lilipodchmod +x ~/.Podman/bin/{podman,lilipod}# use better Arch and Ubuntu images. These images are bigger, but don't take much time to build on using Distroboxmkdir -p~/.cache/containers/rm -rf~/.cache/containers/**ln -sf~/.dotfiles/containers/short-name-aliases.conf ~/.cache/containers/# Podman-composesudo pacman -S python-dotenv --needed --noconfirmcurl -o~/.Podman/bin/podman-compose https://raw.githubusercontent.com/containers/podman-compose/main/podman_compose.pychmod +x ~/.Podman/bin/podman-compose# Conmonexportcwd=$PWDcd~/.Podman/podman/bin/wget"https://github.com/containers/conmon/releases/download/2.1.7/conmon.amd64" -o"conmon"chmod +x ./conmoncd$cwd# NOTE: `fuse-overlayfs` is required for rootful containers to worksudo -E mkdir -p /etc/containerssudo -E cp -f~/.dotfiles/misc/policy.json /etc/containers/# IGNORE THE cp ERROR# for GUI apps to workxhost +si:localuser:$USER&> /dev/null # who needs this output# sudo ln -sf ~/.Podman/bin/** /usr/local/bin echo "ADD 'export TERM=xterm-256color' IN ~/.Podman/bin/* FOR DISTROBOX TO WORK CORRECTLY -> ESP FOR THE DISTROBOX SCRIPT"fi
# COPY THIS FILE OVER TO ~/.cache/containers
## not .config/containers
[aliases]
"fedora"="registry.fedoraproject.org/fedora-toolbox:40"# "fedora"="quay.io/toolbx-images/fedora-toolbox"
"ubuntu"="quay.io/toolbx/ubuntu-toolbox""archlinux"="quay.io/toolbx/arch-toolbox"
Time to play: setting Up Containers
Creating your first Distrobox container is a breeze. Just pick your favorite distro and let Podman work its magic:
distrobox create -i arch -n ArchBTW -I -H~/.home
Note that Fedora - and some other distros such as Gentoo - may need additional setup:
I’ve used -H ~/.home because I’m setting a custom home directory. I wanna keep my home clean!
-I isolates the init system. systemd works inside the container.
Replace arch with your desired distro image, and voila! You’re now inside your cozy little container, ready to tinker to your heart’s content. Of course, you’re not limited to these images.
I’ve chosen these images specifically because they take lesser time to set up on distrobox - more software - such as the X server - preinstalled.
Fun with Distrobox: Interesting Use Cases
Now that you’re armed with Distrobox and Podman, the possibilities are endless! From testing software compatibility across different distros to creating lightweight development environments, let your imagination run wild.
Heck, I’ve even managed to get a full-fledged desktop - COSMIC - working on my setup. I used a Fedora container for this purpose - the COPR package.
Setting up Cosmic on Fedora
You can always check the podman output viapodman logs -f <container name> - podman logs -f Fedsin my case.
Because I’m launching the desktop via a TTY, I need to run DISPLAY=:1 dbus-launch cosmic-session. I’d installed the dbus-x11 package on Fedora for this. I’m quite pleased with the output:
That’s all for now, folks! Hope you enjoyed this dive into the world of Distrobox. Until next time, happy containerizing! 🐳🎉