Distrobox

提供: ArchWiki
2023年8月27日 (日) 16:58時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (一部翻訳)
ナビゲーションに移動 検索に移動

Distrobox は、ホストとの緊密な統合を提供しながら、ホストと異なる Linux のコンテナ化されたバージョンをインストールし、あるディストリビューションで設計されたバイナリを別のディストリビューションで実行することを可能にするコンテナのラッピングレイヤーです。

Distrobox 自体はコンテナマネージャーではなく、Podman または Docker に依存してコンテナを作成します。

Distrobox のドキュメントから:

ターミナル内の任意の Linux ディストリビューションを使用してください。ソフトウェアのバックワードおよびフォワード互換性を有効にし、好きなディストリビューションを自由に使用することができます。Distrobox は、選択した Linux ディストリビューションを使用して、podman または docker を使用してコンテナを作成します。作成されたコンテナは、ホストと緊密に統合され、ユーザーの HOME ディレクトリ、外部ストレージ、外部 USB デバイス、グラフィカルアプリ (X11/Wayland)、およびオーディオの共有が可能になります。

セキュリティへの影響

Distrobox の主な目的は、ホストからコンテナをサンドボックス化することに焦点を当てていない(プロジェクトの緊密な統合の性質上、これは不可能)ため、Distrobox 内で実行されるコンテナは、ホームフォルダーおよび他のいくつかの場所にフルアクセスします。

サンドボックス化された運用モードは現在計画段階にあり、進行状況はこちらでトラッキングできます。

デフォルトで Docker はコンテナを root として実行し、rootful コンテナはホストのファイルシステムに無制限のアクセスを持つため、Docker よりも Podman を使用することを推奨します。Rootless Docker は現在動作していないが、作業中です。

インストール

ルートアクセス権を持つ場合

まず、Podman または Dockerいずれかの ページに従い、Hello World コンテナをインストールして実行できることを確認してください。

パッケージをインストールするには、distrobox または distrobox-gitAUR のいずれかを選択してください。

ルートアクセス権がない場合/イミュータブルなファイルシステムの場合

以下の両方を実行して、CURL を使用して、ホームフォルダに Distrobox と Podman をインストールします。

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

以下の場所を $PATH に追加します。ユーザーごとの環境変数を設定します:

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

コンテナ内でグラフィカルアプリケーションの実行に問題がある場合は、xorg-xhost をインストールし、以下を ~/.bashrc~/.profile 、または ~/.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