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 .json configuration files in there.
There is no need to install anything; Bluefin-DX has all the applications required. These are the steps:
-
Check that docker, podman and distrobox work from a terminal.
-
Create a project folder that you want to develop using vscode by means of a distrobox container. Let’s call it
dbox-project
. -
Take note of the name of the distrobox. You will need it to create its .json configuration file. For the sake of the example, let’s say the distrobox name is
conky-nvidia
. -
Create the folder
nameConfigs
withmkdir ${HOME}/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/nameConfigs
-
Create a .json file with the same name as your distrobox. Example:
conky-nvidia.json
touch ${HOME}/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/nameConfigs/conky-nvidia.json
-
Edit the created file and add this snippet:
{ "remoteUser": "${localEnv:USER}", "settings": { "dev.containers.copyGitConfig": false, "dev.containers.gitCredentialHelperConfigLocation": "none" } }
-
Save the file, exit the editor, and open vscode, closing any folder, or remote connection.
-
Ensure you have the vscode extension DevContainers installed.
-
Go to vscode Settings and search for the keyword Docker Path. You will see that DevContainers has an option for enter an executable there. Type in
podman
. Exit settings. -
Connect to the distrobox by clicking on the icon on the bottom left corner of vscode. Select “Attach to Running Container…”, and pick the distrobox conky-nvidia
You will be connected to your distrobox as ${USER}, not to root anymore.
This is how your vscode workspace should look:
Just like another DevContainer!
This line in the .json file is what makes you the current user automatically:
"remoteUser": "${localEnv:USER}"
If you comment the line you will be logging in as root, which you don’t want.
Screenshots
New
nameConfigs
folder for vscode
DevContainers Docker Path
Open a remote window
conky-nvidia.json location
conky-nvidia.json
Attach to Running Container