Distrobox

提供: ArchWiki
2023年8月27日 (日) 16:50時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (英語版より新規作成)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

Distrobox is a container wrapping layer that allows the user to install containerised versions of Linux that are different to the host while providing tight integration with the host allowing the use of binaries designed for one distribution to run on another.

Distrobox itself is not a container manager and relies on Podman or Docker to create containers.

From the Distrobox documentation:

Use any Linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Distrobox uses podman or docker to create containers using the Linux distribution of your choice. The created container will be tightly integrated with the host, allowing sharing of the HOME directory of the user, external storage, external USB devices and graphical apps (X11/Wayland), and audio.

Security implications

The main goal of Distrobox is not focused on sandboxing the containers from the host (this would be impossible due to the tight integration nature of the project) and as such containers running inside Distrobox will have full access to your home folder as well as a few other locations.

A sandboxed mode of operation is currently in the planning stages, you can track its progress here.

It is recommended to use Podman over Docker since by default Docker will run containers as root and rootful containers will have unrestricted access to your hosts filesystem. Rootless Docker is currently not working though is being worked on.

Installation

With root access

First follow the page for either Podman or Docker and make sure you are able to install and run a Hello World container.

Install either distrobox or distrobox-gitAUR

Without root access/Immutable filesystem

Install Distrobox and Podman to your home folder using CURL by running both of the following:

Distrobox

$ curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --prefix ~/.local

Podman

$ curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/extras/install-podman | sh -s -- --prefix ~/.local

Add the following locations to your $PATH by setting a per user Environment Variable:

$HOME/.local/bin
$HOME/.local/podman/bin

If you have issues with graphical applications running inside your containers then you also need to install xorg-xhost and add the following to ~/.bashrc or ~/.profile or ~/.xinitrc:

xhost +si:localuser:$USER

Uninstalling

Distrobox provides an uninstallation script for rootless installs, to execute it run the following:

$ curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/uninstall | sh -s -- --prefix ~/.local
ノート: This script is only required if you installed rootless, if you installed via Pacman then you should uninstall in the usual way

Usage

ノート:
  • Throughout the following section name is a variable and can be whatever you want. In all cases replace name with the actual name you choose
  • For the full list of supported options in any sub category use --help, for example to see all creation options use distrobox create --help
  • A full list of supported distros along with their image names can be found at https://distrobox.privatedns.org/compatibility/#containers-distros
  • For more advanced usage techniques please see the Distrobox Documentation page at https://distrobox.privatedns.org/usage/usage

To create a new container run the following:

$ distrobox create -n name

To list installed containers run the following:

$ distrobox list

To interact with an installed container run the following:

$ distrobox enter name

or you can send a command directly to a container with:

$ distrobox enter name -- command-to-execute

To stop a running container run the following:

$ distrobox stop name

To delete a container run the following:

$ distrobox rm name

To install a specific distro into a container run the following (in this example its Ubuntu):

$ distrobox create --image ubuntu:22.04

Installations can be fully customised as follows (in this example its a container called test running Gentoo with root access):

$ distrobox create -i docker.io/gentoo/stage3:latest -n test --root

If you need your container to have root access to the host then it is recommended that you use the --root flag over sudo distrobox.

Configuration

It is possible to configure Distrobox in 2 ways, either with a configuration file or by using Environment Variables.

Configuation file

Distrobox checks the following locations for config files, from least important to most important:

  • /usr/share/distrobox/distrobox.conf
  • /usr/etc/distrobox/distrobox.conf
  • /etc/distrobox/distrobox.conf
  • ${HOME}/.config/distrobox/distrobox.conf
  • ${HOME}/.distroboxrc

An example config file is as follows:

container_always_pull="1"
container_generate_entry=0
container_manager="docker"
container_image_default="registry.opensuse.org/opensuse/toolbox:latest"
container_name_default="test-name-1"
container_user_custom_home="$HOME/.local/share/container-home-test"
container_init_hook="~/.local/distrobox/a_custom_default_init_hook.sh"
container_pre_init_hook="~/a_custom_default_pre_init_hook.sh"
non_interactive="1"
skip_workdir="0"

Environment variables

The following variables are available and should be set using a per user Environment Variable:

DBX_CONTAINER_ALWAYS_PULL
DBX_CONTAINER_CUSTOM_HOME
DBX_CONTAINER_IMAGE
DBX_CONTAINER_MANAGER
DBX_CONTAINER_NAME
DBX_CONTAINER_ENTRY
DBX_NON_INTERACTIVE
DBX_SKIP_WORKDIR

See also