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.
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"
}