# Layered-vscode, so hard to make it work with distroboxes. Can we make it reproducible

**URL:** <https://universal-blue.discourse.group/t/layered-vscode-so-hard-to-make-it-work-with-distroboxes-can-we-make-it-reproducible/1682>\
**Category:** General\
**Tags:** developer-experience\
**Created:** [May 14, 2024, 8:41pm UTC](https://universal-blue.discourse.group/t/layered-vscode-so-hard-to-make-it-work-with-distroboxes-can-we-make-it-reproducible/1682 "2024-05-14T20:41:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![f0nzie](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@f0nzie](https://universal-blue.discourse.group/u/f0nzie)\
**Post date:** [May 14, 2024, 8:41pm UTC](https://universal-blue.discourse.group/t/layered-vscode-so-hard-to-make-it-work-with-distroboxes-can-we-make-it-reproducible/1682/1 "2024-05-14T20:41:39Z")

</div>

Already spent few days trying to make **layered-vscode** work with **distrobox** containers!

**distrobox containers** cannot be seen from vscode **DevContainers** out of the box in Bluefin-DX. There are some tricks available in the [distrobox repo](https://distrobox.it/posts/integrate_vscode_distrobox/) to make it work by placing a script, `podman-host`, under ~/.local/bin. Unfortunately, the connection to the **VS Code server** installed in real-time in the container aborts after few seconds because of conflicts either moving, linking, or renaming /var/tmp/.vscode-server inside the container.

Using **podman** by itself, by declaring it in Docker Path in the DevContainer extension settings, kind of partially works. It will login to the distrobox container as **root** , which is an inconvenient at the moment of creating or sharing files with the host. For instance, it will not allow you to save files modified in the container. The ideal scenario is being logged in as ${USER} inside the container.

I successfully have made ${USER} log in to the distrobox container via a **flatpak-installed** vscode along with the **podman-host** script mentioned above. But flatpak-vscode cannot find the **docker** executable anymore. You get that error that says you need to install Docker. I guess this is a side effect of flatpak-vscode not having all rights to access the system files.

There are other clues about accessing distrobox from vscode provided in one of the issues [discussion](https://github.com/89luca89/distrobox/issues/514). It involves adding a JSON configuration file under the ` ${XDG_CONFIG_HOME}/Code/User/globalStorage/ms-vscode-remote.remote-containers/nameConfigs/` folder with the name of the distrobox.

If you continue digging, you find several proposed solutions out there: adding a container.conf file; symbolic linking to `/var/tmp/.vscode-server`; enable the docker service as a user; adding flatpak-spawn binary to the vscode folder; manually removing the folder /home/{USER}/.vscode-server; adding a devcontainer.json to the vscode project; and few more.

What this tells me if that we should work on creating a repeatable and reproducible set of instructions to be able to access all the awesome development capabilities of Fedora Silverblue derivatives. This guide should cover:

- access Docker containers with Docker or Podman on projects available in the host
- access Distrobox containers with layered or flatpak installed vscode
- access to LXC containers from vscode or other similar editor
- access to DevContainers, locally created, via layered or flatpak installed vscode
- access Nix development environments via vscode or other similar code editors

---

<div class="post-metadata">

**Author:** ![m2Giles](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/m2giles/32/471_2.png) [@m2Giles](https://universal-blue.discourse.group/u/m2Giles)\
**Post date:** [May 14, 2024, 9:29pm UTC](https://universal-blue.discourse.group/t/layered-vscode-so-hard-to-make-it-work-with-distroboxes-can-we-make-it-reproducible/1682/2 "2024-05-14T21:29:59Z")

</div>

> access Docker containers with Docker or Podman on projects available in the host

You have a few options here. You can either use the docker-cli, name correct contexts, and use that use docker only options to talk with podman or docker. You need to make sure that you have access to the correct socket.

> access Distrobox containers with layered or flatpak installed vscode

You will need to use Distrobox’s podman-host for this and now you are limited to talking to only podman containers. For the flatpak you need to install the podman-remote extension. The /var/tmp/.vscode-server method works and it’s an unfortunate hack that it is required. What’s better is using unique home’s per distrobox.

> access to LXC containers from vscode or other similar editor

Use the ssh remote machines extension

> access to DevContainers, locally created, via layered or flatpak installed vscode

Layered vscode, this works seamlessly with docker. With Podman you need to add the following run time argument `--userns=keep-id`. There is a lot of little ankle biters with dev containers, but most of the ecosystem is expecting the devcontainer to be using docker in a VM. Flatpak vscode you need to use the podman-remote tool or install the docker-cli inside the flatpak.

Honestly, there are a ton of ways to tackle development. The simplest method with vscode is to use docker with remote dev-containers. That’s what we have enabled by default in Bluefin/Aurora-dx

---

<div class="post-metadata">

**Author:** ![f0nzie](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@f0nzie](https://universal-blue.discourse.group/u/f0nzie)\
**Post date:** [May 14, 2024, 9:41pm UTC](https://universal-blue.discourse.group/t/layered-vscode-so-hard-to-make-it-work-with-distroboxes-can-we-make-it-reproducible/1682/3 "2024-05-14T21:41:21Z")

</div>

> [@m2Giles](#):
>
> you need to install the podman-remote extension

Thanks @m2Giles!  
Is this **podman-remote** a layered package or a vscode extension? Nothing shows up in vscode extensions when searching for **podman**.

---

<div class="post-metadata">

**Author:** ![m2Giles](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/m2giles/32/471_2.png) [@m2Giles](https://universal-blue.discourse.group/u/m2Giles)\
**Post date:** [May 14, 2024, 10:23pm UTC](https://universal-blue.discourse.group/t/layered-vscode-so-hard-to-make-it-work-with-distroboxes-can-we-make-it-reproducible/1682/4 "2024-05-14T22:23:18Z")

</div>

It’s if you are using flatpak. From your host terminal.

Do a `flatpak search podman` and you’ll see it.

---

<div class="post-metadata">

**Author:** ![f0nzie](https://avatars.discourse-cdn.com/v4/letter/f/97f17d/32.png) [@f0nzie](https://universal-blue.discourse.group/u/f0nzie)\
**Post date:** [May 20, 2024, 10:46pm UTC](https://universal-blue.discourse.group/t/layered-vscode-so-hard-to-make-it-work-with-distroboxes-can-we-make-it-reproducible/1682/5 "2024-05-20T22:46:15Z")

</div>

These two fixes should help to write the vscode to Distrobox, DevContainers integration in Silverblue derivatives:

> [@DevContainers and layered-vscode - another bug \[Solved\]](https://universal-blue.discourse.group/t/devcontainers-and-layered-vscode-another-bug-solved/1792):
>
> Just “victorious” after fixing a problem between layered-vscode and Distrobox containers, went on to test DevContainers. It turns out, it crashes the DevContainer creation process when trying to create a new one from the templates in the menu. No, it’s not the added .json config file for a distrobox. The two problems are not related. Even so, I reverted the changes, rebooted with a fresh installation, and still the problem persists. The issue is present in Silverblue-40 as well as Bluefin-DX-39. …

> [@Layered-vscode to distrobox integration - login as ${USER} - \[Solved\]](https://universal-blue.discourse.group/t/layered-vscode-to-distrobox-integration-login-as-user-solved/1782):
>
> I think finally I got it cracked! I found a method to integrate layered-vscode to distrobox containers and logging as ${USER}, instead of root. The trick is on creating an exclusive .json configuration file for each of the distroboxes you plan to enter in for development. This vscode configuration file creation will not occur automatically; you will have to create the folder nameConfigs under ${HOME}/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/, and then drop your .jso…
