3

I tried to use the Dev-Containers form VSCode to connect to my containers in a remote Linux Server. For security reason we cannot create a docker user group since the docker group grants root-level privileges to the user, but I can run the docker command with sudo.

Is there a way to tell Dev-Containers to use sudo for docker commands? Otherwise it gives me the error: "Current user does not have permission to run 'docker'." when trying to attach an existing container.

I tried to search the issues and questions on github and stackoverflow but did not successfully find a solution.

1 Answer 1

4

You can use the dev.containers.dockerPath setting to specify an alternate executable to use for the docker binary.

But since you can only specify an executable and not a commandline with it you would need to write a small wrapper script like

#!/bin/sh

sudo docker "$@"

and then use it with:

{
   // ...
   "dev.containers.dockerPath": "/path/to/sudo-docker.sh"
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! This is working! I think one of my problems is I didn't find the docker path in settings because I was using an old version of Remote - SSH, I updated it to v0.106 and set the docker path as you said and it's working fine now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.