VSCode devcontainer (part 1)

Coding SAP is Eclipse based ADT, it’s Business Application Studio and.. oh sure it’s VSCode.
I’m playing around with CDS, UI5 and CAP. But – and this is important – i don’t want to pollute my system with strange dependencies like npm (see here).

But there is a solution for that.. – using devcontainers in VSCode.

What is a Devcontainer?
“The Visual Studio Code Remote – Containers extension lets you use a Docker container as a full-featured development environment. It allows you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code’s full feature set. A devcontainer.json file in your project tells VS Code how to access (or create) a development container with a well-defined tool and runtime stack. This container can be used to run an application or to separate tools, libraries, or runtimes needed for working with a codebase.” https://code.visualstudio.com/docs/remote/containers
“This means that you can seamlessly switch your entire development environment just by connecting to a different container.” (https://code.visualstudio.com/docs/remote/containers)

It’s nicely explained eg. in: hDJ Adams Boosting tutorial UX with dev containers See also https://code.visualstudio.com/docs/remote/create-dev-container for more details.

The Devcontainer itself can be based eg. on Docker or alternatives like podman.
Sure i’ll go for the later one…

Use podman
Configure Podman

https://opensource.com/article/21/7/vs-code-remote-containers-podman
– Set “File > Preferences > Settings – Extensions – Remote – Containers: Docker Path” to podman
– Enable rootless containers
– Containers are stored at: /home/daniel/.local/share/containers/

Autostart Plugin for Devcontainer
https://bugs.archlinux.org/task/63374
https://code.visualstudio.com/api/advanced-topics/using-proposed-api

$ code-oss --enable-proposed-api ms-vscode-remote.remote-containers
Add using Preferences: Configure Runtime Arguments

A lot of error messages when accessing the container in vscode

I used “Code – OSS” the official Arch Linux open-source release of VSCode.
Instead installing the “Visual Studio Code — Proprietary Microsoft-branded release” from AUR visual-studio-code-bin solved all.. let me repeat ALL the issues.
https://wiki.archlinux.org/title/Visual_Studio_Code

The following part of this post is just to document my suffering…

1) Error: ‘overlay’ is not supported over zfs, a mount_program is required: backing file system is unsupported for this graph driver

https://github.com/containers/podman/issues/8705

adjust file /home/daniel/.config/containers/storage.conf
or copy from /etc/containers/storage.conf first

from
# Default Storage Driver
[storage]
driver = "overlay"
graphroot = "/var/lib/containers/storage"

to
# Default Storage Driver
[storage]
driver = "overlay"
graphroot = "$HOME/.local/share/containers/storage"
[storage.options]
mount_program = "/usr/bin/fuse-overlayfs"

2) Error: error creating runtime static files directory: mkdir /var/lib/containers/storage/libpod: permission denied

see above: Change location of graphroot

3) Error: ‘overlay’ is not supported over zfs, a mount_program is required: backing file system is unsupported for this graph driver

https://www.redhat.com/sysadmin/podman-rootless-overlay

4) raph driver \”zfs\” overwritten by graph driver \”overlay\” from database – delete libpod local files to resolve.

sudo rm -rf ~/.local/share/containers/

5) Current user does not have permission to run’docker’. Try adding the user to the ‘docker’ group.

https://docs.docker.com/engine/install/linux-postinstall/

sudo groupadd docker
sudo usermod -aG docker $USER
reboot

podman info gives a similar error message about “premission denied”.
sudo podman info works.

This path refers to the parameter “runroot” in the file storage.conf
Change the path there to:
runroot = “$HOME/.local/share/containers/storage”

Then:
sudo rm -rf ~/.local/share/containers/

6) error creating build container: writing blob:

Error message: error creating build container: writing blob:
adding layer with blob “sha256:1339eaac5b67d16d6d9f41fb7a7b96f7cebf3ba4beab36cbb60935aa772af583”: ApplyLayer exit status 1 stdout: stderr: potentially insufficient UIDs or GIDs available in user namespace (requested 0:42 for /etc/gshadow): Check /etc/subuid and /etc/subgid if configured locally and run podman-system-migrate: lchown /etc/gshadow: invalid argument

https://www.redhat.com/sysadmin/rootless-podman
https://wiki.archlinux.org/title/Podman#Set_subuid_and_subgid

Files /etc/subuid and /etc/subgid did not exist:

touch /etc/subuid /etc/subgid
usermod --add-subuids 100000-165535 --add-subgids 100000-165535 daniel
podman system migrate

7) Error: unable to find user vscode: no matching entries in passwd file

Error: unable to find user vscode: no matching entries in passwd file

Error: Command failed: podman run –sig-proxy=false -a STDOUT -a STDERR –mount source=/home/daniel/Scratchpad/cds,target=/workspace,type=bind,Z –mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=/home/daniel/Scratchpad/cds -u vscode –userns=keep-id –entrypoint /bin/sh vsc-cds-b47035544783a146bdba602515809639-uid -c echo Container started

in file “devcondainer.json” change “containerUser”: “vscode” to “containerUser”: “root”

8) mkdir: cannot create directory ‘/root’: Permission denied

https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
https://www.redhat.com/sysadmin/container-permission-denied-errors
https://github.com/microsoft/vscode-remote-release/issues/4443#issuecomment-781254405

Rename or create link:

/home/daniel/.local/share/containers/storage/volumes/vscode/_data/vscode-server-oss/bin/linux-x64/92d25e35d9bf1a6b16f7d0758f25d48ace11e5b9/bin/code-server
to: code-server-oss

9) Error: crun: executable file
`/home/node/.vscode-server-oss/bin/3b889b090b5ad5793f524b5d1d39fda662b96a2a/bin/code-server-oss` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found

Workaround:

1) login to the container shell and create a link with ln -s

docker run -it bash

2) Attach to it from VSCode though
“” attach to running container” – keep the upcoming error-message open.

3) Correct the path

In the container:
ls -s ./code-server ./code-server-oss

4) in VSCode press “retry” in the still open error-message.

10) More error to come…

All all the f*** just because i used “Code – OSS” the official Arch Linux open-source release of VSCode.
Instead installing the “Visual Studio Code — Proprietary Microsoft-branded release” from AUR visual-studio-code-bin solved all.. let me repeat ALL the issues.
https://wiki.archlinux.org/title/Visual_Studio_Code

Lessons learned: MS is not to blame for everything… i learned this the hard way..

You may also like...

1 Response

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.