LinuxCommandLibrary

distrobox-enter

Enter a created Distrobox container

TLDR

Enter a Distrobox container

$ distrobox-enter [container_name]
copy

Enter a Distrobox container and run a command at login
$ distrobox-enter [container_name] -- [sh -l]
copy

Enter a Distrobox container without instantiating a tty
$ distrobox-enter [[-n|--name]] [container_name] -- [uptime --pretty]
copy

SYNOPSIS

distrobox-enter container_name [options] [-- command [args...]]

PARAMETERS

container_name
    The name of the Distrobox container to enter. This is typically the first argument after the command name.

-n, --name NAME
    Explicitly specifies the name of the container to enter. This is an alternative to providing the name as a positional argument.

--root
    Enters the container as the root user. If not specified, the command attempts to enter as the current host user.

--user USER
    Enters the container as a specified user within the container. The user must exist in the container.

--dry-run
    Prints the underlying Podman or Docker command that would be executed, without actually running it. Useful for debugging or understanding operations.

--verbose
    Increases the verbosity of the output, showing more details about the execution process.

--tty
    Forces TTY allocation for the command executed inside the container, even if the standard input is not a TTY.

--no-tty
    Prevents TTY allocation for the command executed inside the container, which is useful for scripting or non-interactive environments.

--
    A separator used to indicate that all subsequent arguments are part of the command to be executed inside the container, rather than options for distrobox-enter itself.

command [args...]
    The command and its arguments to be executed non-interactively inside the container. If omitted, an interactive shell is provided.

-h, --help
    Displays the help message for distrobox-enter and exits.

DESCRIPTION

distrobox-enter is a fundamental command within the Distrobox ecosystem, designed to provide seamless access to existing Distrobox containers. It allows users to either obtain an interactive shell inside a specified container or execute a non-interactive command directly within its environment. This is crucial for managing software, developing applications, and performing system operations without polluting the host operating system.

By abstracting the underlying container technology (like Podman or Docker), distrobox-enter simplifies the process of interacting with isolated environments, making it feel as if the containerized applications are running natively on the host. It's an essential tool for leveraging the benefits of Distrobox: consistent development environments, isolation of dependencies, and easy portability across different Linux distributions.

CAVEATS

The specified container must exist and be accessible by the current user. If a command is specified after --, the command will run non-interactively and exit when it finishes, unlike entering a persistent interactive shell.

Permissions within the container are subject to the container's user/group settings and the specified --user or --root options, not directly by the host's permissions.

INTEGRATION WITH HOST

distrobox-enter seamlessly integrates the container environment with the host by mounting the host's home directory (by default), and other necessary paths like `/mnt/wslg` (for WSLg), `/var/run/docker.sock`, etc. This allows host files and applications to be accessed and interacted with from within the container, blurring the line between host and guest environments.

INTERACTIVE VS. NON-INTERACTIVE

Without a command specified after --, distrobox-enter provides an interactive shell (typically `bash` or `zsh` depending on the container image), allowing users to explore and work within the container. When a command is provided after --, it executes that specific command and then exits, making it suitable for scripting or running single tasks without needing to manually exit the container.

HISTORY

Distrobox is a relatively modern tool, gaining popularity in the mid-2020s, especially among Linux developers and users on immutable distributions like Fedora Silverblue. distrobox-enter has been a core component since the project's inception, serving the primary purpose of interacting with the created containerized environments. Its development focuses on providing a seamless, robust, and user-friendly experience for entering and working within these environments, leveraging the power of OCI containers while simplifying their management.

SEE ALSO

distrobox-create(1), distrobox-list(1), distrobox-rm(1), distrobox-exec(1), distrobox(1), podman(1), docker(1)

Copied to clipboard