2022-01-12 20:52:53 +01:00
|
|
|
- [Distrobox](../README.md)
|
2022-07-18 07:43:39 +02:00
|
|
|
- [Integrate VSCode and Distrobox](#integrate-vscode-and-distrobox)
|
2023-06-15 09:30:42 +02:00
|
|
|
- [From distrobox](#from-distrobox)
|
|
|
|
|
- [From flatpak](#from-flatpak)
|
2022-07-18 07:43:39 +02:00
|
|
|
- [First step, install it](#first-step-install-it)
|
|
|
|
|
- [Second step, extensions](#second-step-extensions)
|
|
|
|
|
- [Third step, podman wrapper](#third-step-podman-wrapper)
|
2022-04-05 17:12:42 +02:00
|
|
|
- [Final Result](#final-result)
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# 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](https://vscodium.com/) as an opensource
|
2026-02-10 10:44:26 +01:00
|
|
|
alternative to VSCode. Dev Containers extension works only
|
|
|
|
|
for non-opensource version of VS code. There are community made extensions like
|
|
|
|
|
[DevPod Containers](https://open-vsx.org/extension/3timeslazy/vscodium-devpodcontainers) that work in VSCodium
|
2022-01-12 20:52:53 +01:00
|
|
|
|
2026-02-10 10:44:26 +01:00
|
|
|
This guide has become outdated and you will need to expect that some things broke since then.
|
2022-01-12 20:52:53 +01:00
|
|
|
|
2023-06-15 09:30:42 +02:00
|
|
|
## From distrobox
|
2022-01-12 20:52:53 +01:00
|
|
|
|
2026-02-10 10:44:26 +01:00
|
|
|
Well, you could just install VSCodium in your Distrobox of choice, and export it!
|
2022-01-12 20:52:53 +01:00
|
|
|
|
2026-02-10 10:44:26 +01:00
|
|
|
For example using an Arch Linux container (We use --home so to not clutter our home directory.
|
|
|
|
|
You can change it if you have VSCode configuration in your home directory that you like):
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|
```shell
|
2026-02-10 10:44:26 +01:00
|
|
|
~$ distrobox create --image archlinux:latest --name arch-distrobox --home ./devcontainer
|
2022-01-12 20:52:53 +01:00
|
|
|
~$ distrobox enter --name arch-distrobox
|
|
|
|
|
user@arch-distrobox:~$
|
|
|
|
|
```
|
|
|
|
|
|
2022-04-05 17:12:42 +02:00
|
|
|
Download the deb file
|
|
|
|
|
[HERE](https://github.com/VSCodium/vscodium/releases), or in Arch case just install
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
user@arch-distrobox:~$ sudo pacman -S code
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Now that we have installed it, we can export it:
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
user@ubuntu-distrobox:~$ distrobox-export --app code
|
|
|
|
|
```
|
|
|
|
|
|
2026-02-10 10:44:26 +01:00
|
|
|
For proprietary version you need to use the binary hosted on [AUR](https://aur.archlinux.org/packages/visual-studio-code-bin).
|
|
|
|
|
|
|
|
|
|
To enable and install from AUR do:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
sudo pacman -Syu git base-devel &&\
|
|
|
|
|
git clone https://aur.archlinux.org/yay.git &&\
|
|
|
|
|
cd yay &&\
|
|
|
|
|
makepkg -si &&\
|
|
|
|
|
yay -S visual-studio-code-bin &&\
|
|
|
|
|
distrobox-export --app code
|
|
|
|
|
```
|
|
|
|
|
|
2022-01-12 20:52:53 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
2026-02-10 10:44:26 +01:00
|
|
|
### Manage podman from Distrobox
|
|
|
|
|
|
|
|
|
|
We will use the
|
|
|
|
|
[podman-remote](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/building_running_and_managing_containers/using-the-container-tools-api)
|
|
|
|
|
to manage our containers running on host
|
|
|
|
|
|
|
|
|
|
1. Install
|
|
|
|
|
[Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
|
|
|
|
|
in VSCode
|
|
|
|
|
2. Make sure that podman sockets is enabled on the host system
|
|
|
|
|
`
|
|
|
|
|
ls -l /run/user/$(id -u)/podman/podman.sock
|
|
|
|
|
`
|
|
|
|
|
if it isn't, enable it with:
|
|
|
|
|
`
|
|
|
|
|
systemctl --user enable --now podman.socket
|
|
|
|
|
`
|
|
|
|
|
3. Inside the Distrobox install podman to provide `podman-remote`
|
|
|
|
|
`
|
|
|
|
|
sudo pacman -Syu podman
|
|
|
|
|
`
|
|
|
|
|
4. Check if it's working by running:
|
|
|
|
|
`
|
|
|
|
|
podman-remote info
|
|
|
|
|
`
|
|
|
|
|
5. Configure Dev Containers Extension by putting `podman-remote` in
|
|
|
|
|
[vscode://settings/dev.containers.dockerPath](vscode://settings/dev.containers.dockerPath)
|
|
|
|
|
6. If you click refresh in Dev Containers extension you should see your host's containers
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2023-06-15 09:30:42 +02:00
|
|
|
## From flatpak
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|
Alternatively you may want to install VSCode on your host. We will explore how
|
|
|
|
|
to integrate VSCode installed via **Flatpak** with Distrobox.
|
|
|
|
|
|
2024-02-20 18:53:21 +01:00
|
|
|
For this one you'll need to use VSCode from Microsoft, and not VSCodium, in order
|
|
|
|
|
to have access to the remote containers extension.
|
|
|
|
|
|
2022-07-18 07:43:39 +02:00
|
|
|
### First step install it
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|
```shell
|
2024-06-20 16:01:24 +02:00
|
|
|
~$ flatpak install --user app/com.visualstudio.code
|
2022-01-12 20:52:53 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Second step, extensions
|
|
|
|
|
|
2023-06-10 08:53:58 -07:00
|
|
|
Now we want to install VSCode [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2022-07-18 07:43:39 +02:00
|
|
|
### Third step podman wrapper
|
2022-01-12 20:52:53 +01:00
|
|
|
|
2024-06-20 16:01:24 +02:00
|
|
|
Being in a Flatpak, we will need access to host's `podman` to be
|
2022-04-05 17:12:42 +02:00
|
|
|
able to use the containers. Place this in your `~/.local/bin/podman-host`
|
2024-06-20 16:01:24 +02:00
|
|
|
In case of access to host's `docker` to be
|
|
|
|
|
able to use the containers, use `~/.local/bin/docker-host`
|
|
|
|
|
|
|
|
|
|
For podman:
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|
```shell
|
2024-02-20 18:53:21 +01:00
|
|
|
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/extras/podman-host -o ~/.local/bin/podman-host
|
|
|
|
|
chmod +x ~/.local/bin/podman-host
|
2022-01-12 20:52:53 +01:00
|
|
|
```
|
|
|
|
|
|
2024-06-20 16:01:24 +02:00
|
|
|
For docker:
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/extras/docker-host -o ~/.local/bin/docker-host
|
|
|
|
|
chmod +x ~/.local/bin/docker-host
|
|
|
|
|
```
|
|
|
|
|
|
2022-01-12 20:52:53 +01:00
|
|
|
Open VSCode settings (Ctrl+,) and head to `Remote>Containers>Docker Path` and
|
2024-06-20 16:01:24 +02:00
|
|
|
set it to the path of `/home/<your-user>/.local/bin/podman-host` (or docker-host in case of docker), like in the example
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2022-04-05 17:12:42 +02:00
|
|
|
This will give a way to execute host's container manager from within the
|
|
|
|
|
flatpak app.
|
2022-01-12 20:52:53 +01:00
|
|
|
|
|
|
|
|
## 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!
|
|
|
|
|
|
|
|
|
|

|
2024-02-20 18:53:21 +01:00
|
|
|
|
|
|
|
|
# Open VSCode directly attached to our Distrobox
|
|
|
|
|
|
|
|
|
|
You may want to instead have a more direct way to launch your VSCode when you're already in your project directory,
|
|
|
|
|
in this case you can use `vscode-distrobox` script:
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/extras/vscode-distrobox -o ~/.local/bin/vscode-distrobox
|
|
|
|
|
chmod +x ~/.local/bin/vscode-distrobox
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
This will make it easy to launch VSCode attached to target distrobox, on a target path:
|
|
|
|
|
|
|
|
|
|
`vscode-distrobox my-distrobox /path/to/project`
|