DistroBox – Run Any Linux Distribution Inside Linux Terminal

Distrobox is a nifty tool that allows you to create and manage containers on your favorite Linux distribution using either Docker or Podman. The launched container becomes highly integrated with the host system and this allows sharing of the user’s HOME directory along with external storage, USB devices, and graphical applications.

Distrobox is based on an OCI image and implements similar concepts to those of ToolBox which is built on top of podman and OCI standard container technologies.

In this guide, we will demonstrate how to install DistroBox to run any Linux distribution inside your Linux terminal. For this guide, we are running Fedora 34.

Prerequisites

Before you proceed, ensure you have the following:

  • Minimum podman version: 2.1.0 or docker version: 18.06.1.

Step 1: Install DistroBox on Linux System

Installing DistroBox is a piece of cake. Simply run the following curl command which downloads and run the installation script.

$ curl https://raw.githubusercontent.com/89luca89/distrobox/main/install | sudo sh
Install DistroBox in Fedora
Install DistroBox in Fedora

In Fedora, DistroBox is available from the Copr repository. So, enable the Copr repository on Fedora.

$ sudo dnf copr enable alciregi/distrobox
Install Copr Repository in Fedora
Install Copr Repository in Fedora

Once the Copr repository has been added, use the DNF package manager to install Distrobox.

$ sudo dnf install distrobox
Install DistroBox from Copr Repository
Install DistroBox from Copr Repository

Step 2: Create a Container from an Image

With Distrobox installed, we can now get started with creating and running containers. To pull an image and run a container from the image, use the distrobox-create command as follows.

$ distrobox-create --name container-name --image os-image:version

In this example, we are creating a container called debian10-distrobox from the Debian 10 image.

$ distrobox-create --name debian10-distrobox --image debian:10

The command pulls the Debian 10 image from Docker Hub and creates a container called debian10-distrobox.

To get a complete list of operating systems and versions supported by Distrobox containers, visit the Distrobox Project page.

Create Distrobox Container Image
Create Distrobox Container Image

To list containers created with Distrobox, run:

$ distrobox-list
List Distrobox Container Images
List Distrobox Container Images

Step 3: Accessing a Distrobox Container

To access the shell of the newly created Linux container, use the distrobox-enter command as follows:

$ distrobox-enter --name container-name

For example, to access our container, we will run the command:

$ distrobox-enter --name debian10-distrobox

From here, you can run commands inside the container. For example, the following command checks the OS version.

$ cat /etc/os-release
Check Distrobox Linux Container Version
Check Distrobox Linux Container Version

You can also install applications. Here, we are installing the Neofetch utility tool.

$ sudo apt install neofetch

Once Neofetch is installed, launch it as follows.

Neofetch Show Linux Information
Neofetch Show Linux Information

Step 4: Run Commands On Distrobox Container

You can directly run the commands on a Distrobox container instead of accessing the shell using the syntax shown.

$ distrobox-enter --name container-name  -- command

In the following commands, we are displaying the uptime of the container and updating the package lists respectively.

$ distrobox-enter --name debian10-distrobox -- uptime
$ distrobox-enter --name debian10-distrobox -- sudo apt update
Run Commands on Distrobox Linux Container
Run Commands on Distrobox Linux Container

Step 5: Exporting Applications from Container to Host

In case you have an application inside the Distrobox container that you would like to port to the host system, you can do so using the distrobox-export command. Bur first, access the container’s shell.

$ distrobox-enter --name container-name

Here, we are going to install Flameshot which is a free and open-source cross-platform tool for taking screenshots.

$ sudo apt install flameshot

To export the application to Fedora, we will run the command:

$ distrobox-export --app flameshot
Export Applications from Container to Host
Export Applications from Container to Host

To exit the container, run:

$ logout

Now back to the Fedora host system. To confirm the existence of the application, we will run the search for the application using the Application menu as follows.

Check Exported App in Fedora
Check Exported App in Fedora

Step 6: Cloning a Distrobox Container

Sometimes, you might need to create a duplicate or a clone of a container image. To achieve this, first, stop the running container using the podman command

$ podman stop container_ID

To get the container ID, run the podman ps command to list currently running containers.

$ podman ps

Once the container is stopped, you can create a duplicate as follows. In this example, we are duplicating the debian10-distrobox distrobox to a clone called debian-10-clone.

$ distrobox-create --name debian-10-clone --clone debian10-distrobox
Cloning Distrobox Linux Container
Cloning Distrobox Linux Container

To confirm that the clone has been created, yet again, list the Distrobox containers as shown.

$ distrobox-list
List Distrobox Cloned Images
List Distrobox Cloned Images

Step 7: Managing Distroboxes in Fedora

In this last section, we will briefly go over how to manage containers using podman.

To list all active containers, run:

$ podman ps
List Distrobox Active Containers
List Distrobox Active Containers

To list all running containers both active and those that have exited, run:

$ podman ps -a

To stop a container, run the command:

$ podman stop container_ID

To remove a container, be sure to stop it first and then remove it.

$ podman stop container_ID
$ podman rm  container_ID
Stop Distrobox Container Images
Stop Distrobox Container Images
Conclusion

Distrobox is a handy utility that allows forward and backward compatibility with software applications and also enables you to try out various Linux distributions in form of containers without requiring sudo privileges.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

8 Comments

Leave a Reply
  1. Give this a try to run a browser in the container. Seems to work great except you can’t play any videos in the browser because the distrobox container won’t export sound to the host sound card.

    I’ll start researching to see if there’s a way around this, but probably won’t be able to run any apps that need access to the host hardware I guess.

    Reply
  2. Thanks, Ravi for the procedures depicted here!

    Except for a couple of individual issues, the Distrobox procedure worked just fine.

    Regards

    Reply
  3. I want to update my old Fedora to the latest version (above Fedora 34).

    I’m looking for detailed instructions. Please help

    Reply
      • @Ravi

        Thanks for the response. Much appreciated.

        Could you please describe more on it, like why is it not possible in any way!?

        Will, it not work from step by step upgrade like 17 to 18 and from 18 to next stable version upgrade until we reach to latest version!?

        Request to describe in detail, for good understanding.

        Reply
        • @Suresh,

          Yes, it will work like upgrading from Fedora 17 to 18, 18-19, and so on until you reach to the latest, but the time it will take, I have no idea.

          So I suggest, better to have a fresh Fedora install..

          Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.