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.
This details how we can install and setup Distrobox.
Important
Ensure the path to ~/.local/bin is in your ${PATH} environment variable.
-
If your system does not already have a container runtime (i.e. Docker) set up, install Podman.
-
Install
distrobox:curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --prefix ~/.local
-
In order to have graphical applications working, set up a
~/.distroboxrcprofile:xhost +si:localuser:${USER} export PATH=${PATH}:${HOME}/.local/binIf you are setting this up on SteamOS (Steam Deck), an additional line is needed to force the use of
pulseaudioin the container:xhost +si:localuser:${USER} export PIPEWIRE_RUNTIME_DIR=/dev/null export PATH=${PATH}:${HOME}/.local/bin
This details how we can use Distrobox by creating, entering, and managing containers.
-
Create a home directory for our Distrobox container (i.e.
ubuntu):mkdir -p ~/distrobox/ubuntu -
Create a Distrobox container based on i.e. Ubuntu 22.04, named
ubuntu, with a custom${HOME}directory:distrobox create --image docker.io/library/ubuntu:22.04 --name ubuntu --home ~/distrobox/ubuntu -
Enter a Distrobox container named i.e.
ubuntu:distrobox enter ubuntu -nw
[!NOTE]
The-nwflag is optional and is used to send the user directly to the container's home directory.You may exit the container by using the Ctrl + D key combination or running the following command:
exit -
To stop and delete a Distrobox container named i.e.
ubuntufrom the host system:distrobox stop ubuntu && distrobox rm ubuntu -
To run commands on the host system from inside a Distrobox container, use the
distrobox-host-execcommand:distrobox-host-exec flatpak run com.google.Chrome
This example runs the
flatpakcommand on the host system from inside the Distrobox container.
This details how we can install certain applications or libraries not present in your system via Distrobox.
Note
We recommend an Arch Linux based Distrobox container for maximum software availability, but any Distrobox container would do.
-
Create a home directory for our Distrobox container (i.e.
arch):mkdir -p ~/distrobox/arch -
Create an Arch Linux based Distrobox container:
distrobox create --image docker.io/library/archlinux --name arch --home ~/distrobox/arch -
Enter our Distrobox container (i.e.
arch):distrobox enter arch -nw
-
Install the application or library we desire. For example, install the
unrarpackage usingyayinside the container. -
Export the binary we had installed,
unrarfrom the container so that we have access to it on our desktop:distrobox-export --bin $(which unrar) --export-path /home/${USER}/.local/bin
You can also change the
export-pathto where your preferred destination is, i.e./usr/local/bin. -
We could also do the same with a desktop application.
For example, install the
notableapplication usingyayinside the container.Export the application,
notable:distrobox-export --app notable
-
To remove an exported binary or application at some point in the future, simply use the same command we had used to export them with an additional flag
--deletefrom the same container.For example:
distrobox-export --bin $(which unrar) --export-path /home/${USER}/.local/bin --delete
This allows attaching to a Distrobox Container from within VS Code (on the host system) like you would on Windows with WSL.
Note
This guide assumes that you are using the Flatpak version of VS Code.
-
Install the Dev Containers extension on VS Code.
-
Create a
podmanwrapper from within the Distrobox container to access the host'spodman(ordocker) in~/.local/bin/podman-host:nano ~/.local/bin/podman-hostContent of
podman-host:#!/bin/bash set -x if [ "$1" == "exec" ]; then # Remove 'exec' from $@ shift script=' result_command="podman exec" for i in $(printenv | grep "=" | grep -Ev " |\"" | grep -Ev "^(HOST|HOSTNAME|HOME|PATH|SHELL|USER|_)"); do result_command=$result_command --env="$i" done exec ${result_command} "$@" ' exec flatpak-spawn --host sh -c "$script" - "$@" else exec flatpak-spawn --host podman "$@" fi
-
Make the
podman-hostscript executable:chmod +x ~/.local/bin/podman-host -
Open up VS Code and head to Settings by pressing Ctrl + ,.
-
Add the
podman-hostscript as the Docker Path under the Dev > Containers: Docker Path setting./home/<container-user>/.local/bin/podman-hostReplace
<container-user>with the user of your container. -
From the host system, make the container findable/recognisable from within VS Code by creating a
jsonfile with the name of your container.Create the
jsonfile at~/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/cli-bin/<container-name>.json:nano ~/.var/app/com.visualstudio.code/config/Code/User/globalStorage/ms-vscode-remote.remote-containers/cli-bin/<container-name>.json
Replace
<container-name>with the name of your container (i.e.arch).Content of the
<container-name>.jsonfile:{ "name" : "", // PUT YOUR DISTROBOX NAME HERE "remoteUser": "${localEnv:USER}", "settings": { "remote.containers.copyGitConfig": false, "remote.containers.gitCredentialHelperConfigLocation": "none", "terminal.integrated.profiles.linux": { "shell": { "path": "${localEnv:SHELL}", "args": [ "-l" ] } }, "terminal.integrated.defaultProfile.linux": "shell" }, "remoteEnv": { "COLORTERM": "${localEnv:COLORTERM}", "DBUS_SESSION_BUS_ADDRESS": "${localEnv:DBUS_SESSION_BUS_ADDRESS}", "DESKTOP_SESSION": "${localEnv:DESKTOP_SESSION}", "DISPLAY": "${localEnv:DISPLAY}", "LANG": "${localEnv:LANG}", "SHELL": "${localEnv:SHELL}", "SSH_AUTH_SOCK": "${localEnv:SSH_AUTH_SOCK}", "TERM": "${localEnv:TERM}", "VTE_VERSION": "${localEnv:VTE_VERSION}", "XDG_CURRENT_DESKTOP": "${localEnv:XDG_CURRENT_DESKTOP}", "XDG_DATA_DIRS": "${localEnv:XDG_DATA_DIRS}", "XDG_MENU_PREFIX": "${localEnv:XDG_MENU_PREFIX}", "XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR}", "XDG_SESSION_DESKTOP": "${localEnv:XDG_SESSION_DESKTOP}", "XDG_SESSION_TYPE": "${localEnv:XDG_SESSION_TYPE}" } }Be sure to add the name of your container to the
namefield. -
To attach the container from within VS Code in the host system, open the Command Palette by pressing Ctrl + Shift + P.
-
Search and click the Attach to Running Container option.
-
Click the name of the container we have configured (i.e.
arch).