Integrate VSCode and Distrobox

VScode doesn’t need presentations, and it’s a powerful tool for development. You may want to use it, but how to handle the dualism between host and container?

In this experiment we will use VSCodium as an opensource alternative to VSCode.

Here are a couple of solutions.

From distrobox

Well, you could just install VSCode in your Distrobox of choice, and export it!

For example using an Arch Linux container:

~$ distrobox create --image archlinux:latest --name arch-distrobox
~$ distrobox enter --name arch-distrobox

Download the deb file HERE, or in Arch case just install

user@arch-distrobox:~$ sudo pacman -S code

Now that we have installed it, we can export it:

user@ubuntu-distrobox:~$ distrobox-export --app code

And that’s really it, you’ll have VSCode in your app list, and it will run from the Distrobox itself, so it will have access to all the software and tools inside it without problems.

image image

From flatpak

Alternatively you may want to install VSCode on your host. We will explore how to integrate VSCode installed via Flatpak with Distrobox.

First step install it

~$ flatpak install --user app/com.visualstudio.code

Second step, extensions

Now we want to install VSCode Dev Containers extension


Third step podman wrapper

Being in a Flatpak, we will need access to host’s podman (or docker) to be able to use the containers. Place this in your ~/.local/bin/podman-host

set -x

# This little workaround is used to ensure
# we use our $USER inside the containers, without
# resorting to creating devcontainer.json or similar stuff
for i in "${!arr[@]}"; do
    if [[ ${arr[$i]} == *"root:root"* ]]; then
        arr[$i]="$(echo "${arr[$i]}" | sed "s|root:root|$USER:$USER|g")"

flatpak-spawn --host podman "${arr[@]}"

and make it executable: chmod +x ~/.local/bin/podman-host.

Open VSCode settings (Ctrl+,) and head to Remote>Containers>Docker Path and set it to the path of podman-host, like in the example


This will give a way to execute host’s container manager from within the flatpak app.

Final Result

After that, we’re good to go! Open VSCode and Attach to Remote Container:


And let’s choose our Distrobox


And we’re good to go! We have our VSCode remote session inside our Distrobox container!