Distrobox - Create and Manage Linux Containers

Learn how to use Distrobox to create, manage, and export Linux containers. Explore commands for creating, listing, entering, exporting apps/bins/services, upgrading, cloning, stopping, and removing Distrobox containers.

Distrobox Commands

Distrobox allows you to run any Linux distribution inside a container, seamlessly integrating it with your host system. This makes it easy to experiment with different environments, develop applications in isolated setups, or use tools that are not readily available on your primary OS. Below are common Distrobox commands and their usage.

Distrobox Creation and Management

These commands are essential for setting up and managing your Distrobox containers.

Creating a Distrobox

To create a new Distrobox, you specify a container name and the desired Linux distribution image. For example, to create a Distrobox using the latest Ubuntu image:

distrobox-create <container_name> --image <ubuntu:latest>

Listing Distroboxes

To see all your Distrobox containers and their details, use the distrobox-list command. The --verbose flag provides more in-depth information.

distrobox-list --verbose

Entering a Distrobox

Once created, you can enter your Distrobox environment using distrobox-enter.

distrobox-enter <container-name>

Interacting with the Host System

Distrobox provides mechanisms to execute commands on your host system from within a container and to export applications and services.

Executing Commands on the Host

The distrobox-host-exec command allows you to run commands on your host system while you are inside a Distrobox container.

distrobox-host-exec <command>

Exporting Applications and Binaries

You can export applications, binaries, and services from your Distrobox container to your host system, making them accessible as if they were installed directly on the host.

Exporting an application (e.g., Atom):

distrobox-export --app <atom> --extra-flags "--foreground"

Exporting a binary (e.g., ranger):

distrobox-export --bin </usr/bin/ranger> --export-path <$HOME/.local/bin>

Exporting a service (e.g., Syncthing): The --sudo flag can be used to run the service as root inside the container.

distrobox-export --service <syncthing> --extra-flags "--allow-newer-config" --sudo

Unexporting Applications

To remove an exported application from your host system:

distrobox-export --app <atom> --delete

Container Maintenance and Removal

Keep your Distrobox environments up-to-date and manage their lifecycle with these commands.

Upgrading a Distrobox

Update the packages within a Distrobox container using its native package manager:

distrobox-upgrade <container_name>

Cloning a Distrobox

Create an exact copy of an existing Distrobox container:

distrobox-create --clone <container_name> <cloned_container_name>

Stopping a Distrobox

Gracefully stop a running Distrobox container:

distrobox-stop <container-name>

Removing a Distrobox

To remove a Distrobox container. Use the --force flag for a forceful removal.

distrobox-rm <container_name> --force

Further Resources

For more in-depth information and advanced usage, refer to the official Distrobox documentation and related container technologies.