VS Code attach to container in k8s fails with mkdir: cannot create directory '/var/www': Permission denied

5/24/2021

Running VS code on Ubuntu 20.10

Based on this guide:

https://code.visualstudio.com/docs/remote/attach-container#_attach-to-a-container-in-a-kubernetes-cluster

I am trying to attach to a running container in a k8s cluster and edit a file in that container using vs code:

enter image description here

As a result another vs code instance opens but prints this error:

[2260 ms] 
[2261 ms] mkdir: cannot create directory '/var/www': Permission denied
[2261 ms] Exit code 1
[2274 ms] Command in container failed: mkdir -p /var/www/.vscode-server/bin/054a9295330880ed74ceaedda236253b4f39a335_1621844063707

Looks like its trying to create that directory in the remote container but is that necessary to connect and open/edit a file on the remote container in vs code?

Or is it somehow possible to specify a path for where to store this content inside the container with adequate permissions?

-- u123
docker
kubernetes
visual-studio-code

1 Answer

5/28/2021

It seems that your option Attach Visual Studio Code does not originate from the official Kubernetes extension from VS Code.

You can visit this open issue on GitHub to learn more about it.

-- Abhinav Thakur
Source: StackOverflow