Hey y'all,
So recently I've been playing around with this tool called Distrobox, which uses docker (or podman) to create, well distros in a container, but that's not where the fun ends... you can use applications from within the container on your host as if native. This brings with it all the goodness from other distros
and package managers, like for example using the Arch AUR on your Ubuntu install. Let me explain...
Distrobox is a wrapper for podman or docker (whatever you prefer). The reason Distrobox exists is to integrate the containers within your system, as if it were native software.
A few things that it integrates into are removable devices (USB storage devices), D-Bus, user's $HOME directory, Wayland and X11 sockets, and much more!
Long story short:
Distrobox is a way to make containerized software integrate like native apps, even if that containerized software belongs to a different distribution altogether.
The best thing about it, you get to build a development environment without requiring root privileges. You do not have to change your host distribution just because of software compatibility issues. You can keep using what you're comfortable with and use Distrobox to fill the gap for backward/forward software compatibility using any other Linux distribution.
Now that you have an idea about Distrobox, what does it let you do overall? Are
the functionalities useful to your use-case?
Let me mention the key highlights for Distrobox:
* Ability to make a test environment for making changes without affecting your host distribution.
* A development environment that does not need sudo privileges can be flexible for your work. For instance, if you have a work laptop, a sudoless setup can help you.
* Easy way to manage multiple environments.
* Supports a variety of distributions.
How to install Distrobox?
There is a prerequisite for installing Distrobox. That is, you must have either
podman or docker installed. If you have a
relatively modern Linux distribution, I recommend installing podman from your software repositories. Otherwise, install docker and follow the steps mentioned
below.
At the time of writing this, Distrobox is available in the following repositories:
* Arch Linux (AUR)
* EPEL 8 and later
* Fedora 34 and later
* Ubuntu 22.10 and later
As you might have noticed, the latest version of Ubuntu available to the wider public is Ubuntu 22.04. Not many distributions
have Distrobox packaged yet...
If you do not find it in the repositories, you can run the following command to
install Distrobox:
curl -s
https://raw.githubusercontent.com/89luca89/distrobox/main/install|sudo sh
The above command will download a shell script and run it with superuser privileges. In case you cannot verify the source yourself, below is the command
you can use without feeling anxious about granting superuser privilege to an unknown script.
curl -s
https://raw.githubusercontent.com/89luca89/distrobox/main/install|sh -s
-- --prefix ~/.local
Now that you have Distrobox installed, let us proceed to a few examples of using it.
1. Create a new container
A 'container' in this context refers not to a containerized software like nextcloud, syncthing, etc but rather an operating system itself.
The syntax to create a new container is as follows:
distrobox-create --name CONTAINER-NAME --image OS-NAME:VERSION
In here, you can specify what name you wish to address your container by (CONTAINER-NAME), the name of OS you want to use (OS-NAME) and it's version (VERSION)
Let us take a look at how to create a new container for Fedora 36 with the name
'fedorabox'. I will do so with the following command:
distrobox-create --name fedora36 --image fedora:36
You may also substitute '36' with 'latest' in case you want the latest version of any operating system.
This command will only take a moment to download the container image for Fedora
36.
Once the process finishes, you will get a message letting you know that the container was created.
2. Start and enter the container
An OS container is of no use if we do not start it and access its shell.
To do so, use the 'distrobox-enter' command. The syntax is as follows:
distrobox-enter CONTAINER-NAME
When you start the container for the first time, Distrobox will do an automatic
initial setup of installing a few containers, setting up the mounts, themes, icons, fonts, groups, users and more.
Based on your computer's processing power, this may take quite a long time. Please be patient. On my Ryzen 5 2600X it takes just over 60 seconds, so unless
you're running ancient hardware it should be relatively ok.
When that is completed, you will be dropped in the shell of the container automatically.
christian@uvavu:~$ distrobox-create --name fedora36 --image fedora:36
Image fedora:36 not found.
Do you want to pull the image now? [Y/n]: Y
36: Pulling from library/fedora
d2c625b3c719: Pull complete
Digest: sha256:b3cc6f8a5c866c08a400c1bab3292684ecda8f3d1f7a37641a80c65bccfbe2ce Status: Downloaded newer image for fedora:36
docker.io/library/fedora:36
Creating 'fedora36' using image fedora:36 [ OK ]
Distrobox 'fedora36' successfully created.
To enter, run:
distrobox-enter fedora36
fedora36
christian@uvavu:~$ distrobox-enter fedora36
Container fedora36 is not running.
Starting container fedora36
run this command to follow along:
docker logs -f fedora36
Starting container... [ OK ]
Installing basic packages... [ OK ]
Setting up read-only mounts... [ OK ]
Setting up read-write mounts... [ OK ]
Setting up host's sockets integration... [ OK ]
Integrating host's themes, icons, fonts... [ OK ]
Setting up package manager exceptions... [ OK ]
Setting up rpm exceptions... [ OK ]
Setting up sudo... [ OK ]
Integrating host's themes, icons, fonts... [ OK ]
Setting up package manager exceptions... [ OK ]
Setting up rpm exceptions... [ OK ]
Setting up sudo... [ OK ]
Setting up groups... [ OK ]
Setting up users... [ OK ]
Executing init hooks... [ OK ]
Container Setup Complete!
christian@fedora36:~$
After the above, you can see I'm now inside this container's shell. The hostname has changed to the name I gave the container in step 1.
christian@fedora36:~$ grep VERSION /etc/os-release
VERSION="36 (Container Image)"
VERSION_ID=36
VERSION_CODENAME=""
REDHAT_BUGZILLA_PRODUCT_VERSION=36
REDHAT_SUPPORT_PRODUCT_VERSION=36
3. Install software
If you have reached this stage, this is the equivalent of freshly installing Fedora on your computer and the OS just booted.
Just like a virtual machine, the OS on our host machine does not matter. We have to use the package manager provided by the guest OS. Hence, I will be using the DNF package manager on Fedora 36.
My host operating system, Ubuntu 22.04 LTS, does not [yet] have Foliate in the first party repositories. But Fedora 36 has Foliate in the first party repositories. This way, I can easily install Foliate as a native software without making use of heavy virtualization.
So, let us install Foliate, since it is available in Fedora's repositories but not in Ubuntu's repositories.
sudo dnf install foliate.noarch
After dnf finishes installing Foliate, I will run the following command (inside
the container shell) as well:
distrobox-export --app foliate
When you run the 'distrobox-export' command from the container, it will make the specified software available to the host operating system as well. This means, even though Foliate is installed inside the Fedora container, I will be able to see it in Ubuntu's Application Menu.
4. Managing Distrobox images
Distrobox provides a few commands that can be used to manage Distrobox images.
The first command is 'distrobox list'. As evident from the name, it lists all the containers that are installed.
christian@uvavu:~$ distrobox list
ID | NAME | STATUS | IMAGE 9895140fb5bb | fedora36 | running | fedora:36
1a63bb533f1f | centos9 | exited | quay.io/centos/centos:stream9
bd34cd153fda | tumbleweed | exited | registry.opensuse.org/opensuse/tumbleweed:latest
ff7549554421 | arch | exited | archlinux:latest
As you can see, I have a few containers already set up, but stopped, and the one we just created that is running.
The second command is 'distrobox stop'. This command is used to stop a running container.
Below is the syntax:
distrobox stop CONTAINER-NAME
christian@uvavu:~$ distrobox stop fedora36
Do you really want to stop fedora36? [Y/n]: Y
fedora36
Finally, to delete any Distrobox container, use the 'distrobox rm' command. The
syntax is given below:
distrobox rm CONTAINER-NAME
christian@uvavu:~$ distrobox rm fedora36
Do you really want to delete fedora36? [Y/n]: Y
fedora36
fedora36
To explore more technical details, head to its [GitHub page](
https://github.com/89luca89/distrobox).
Conclusion
Distrobox is a wonderful tool that allows you to install operating systems as a
simple podman/docker container and use them as a full-fledged operating system.
Using Distrobox you can install virtually any software, even if it is not available in your distribution's repositories, or even if it is not packaged for your Linux distribution. How useful is that?
There can be various use-cases for Distrobox. What do you think you will be using it for? Share your thoughts with us here.
Extra thoughts:
For most of the commands you can instead of using example distrobox-list or distrobox-enter you can replace the - with a space, with that I have aliased "distrobox" to "db" for ease of use, so instead of "distrobox-enter CONTAINER-NAME" I just do "db enter CONTAINER-NAME".
My bash alias looks like;
alias db="distrobox"
(For more on this article, check out this url:
https://itsfoss.com/distrobox/)
---
|14Best regards,
|11Ch|03rist|11ia|15n |11a|03ka |11Me|03aTLoT|11io|15N
|07ÄÄ |08[|10eml|08] |
15ml@erb.pw |07ÄÄ |08[|10web|08] |15www.erb.pw |07ÄÄÄ¿ |07ÄÄ |08[|09fsx|08] |1521:1/158 |07ÄÄ |08[|11tqw|08] |151337:1/101 |07ÂÄÄÙ |07ÄÄ |08[|12rtn|08] |1580:774/81 |07ÄÂ |08[|14fdn|08] |152:250/5 |07ÄÄÄÙ
|07ÄÄ |08[|10ark|08] |1510:104/2 |07ÄÙ
--- Mystic BBS v1.12 A48 2022/07/15 (Linux/64)
* Origin: thE qUAntUm wOrmhOlE, rAmsgAtE, uK. bbs.erb.pw (1337:1/101)