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.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

7 thoughts on “DistroBox – Run Any Linux Distribution Inside Linux Terminal”

  1. 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

Leave a Reply to Jalal Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.