Docker in Docker on envbuilder has permission issues on non-root user Devcontainers.

Hi all, I was able to run native Coder on my Linux machine, and everything is now working. My question is just that when I use Envbuilder to build devcontainer, the docker socket runs properly, but I can't seem to apply the necessary Docker permissions on the coder user, only the root has access to docker CLI. I am using sysbox, my resource "docker_container" contains
{
...
runtime = "sysbox-runc"
restart = "always"
...
}
{
...
runtime = "sysbox-runc"
restart = "always"
...
}
For reference, I already tried these commands below, I also logged in to another shell, but the same issue persists.
coder@turquoise-muskox-97:/workspaces$ sudo usermod -aG docker coder
coder@turquoise-muskox-97:/workspaces$ newgrp docker
coder@turquoise-muskox-97:/workspaces$ groups
docker root
coder@turquoise-muskox-97:/workspaces$ sudo chmod -R 777 /var/run/docker.sock
coder@turquoise-muskox-97:/workspaces$ sudo ls -l /var/run/docker.sock
srwxrwxrwx 1 root docker 0 Apr 21 01:46 /var/run/docker.sock
coder@turquoise-muskox-97:/workspaces$ id
uid=1000(coder) gid=997(docker) groups=997(docker),0(root)
coder@turquoise-muskox-97:/workspaces$ ls -l /var/run/docker.sock
ls: cannot access '/var/run/docker.sock': Permission denied
coder@turquoise-muskox-97:/workspaces$ docker run hello-world
docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Head "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied

Run 'docker run --help' for more information
coder@turquoise-muskox-97:/workspaces$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

...

For more examples and ideas, visit:
https://docs.docker.com/get-started/

coder@turquoise-muskox-97:/workspaces$
coder@turquoise-muskox-97:/workspaces$ sudo usermod -aG docker coder
coder@turquoise-muskox-97:/workspaces$ newgrp docker
coder@turquoise-muskox-97:/workspaces$ groups
docker root
coder@turquoise-muskox-97:/workspaces$ sudo chmod -R 777 /var/run/docker.sock
coder@turquoise-muskox-97:/workspaces$ sudo ls -l /var/run/docker.sock
srwxrwxrwx 1 root docker 0 Apr 21 01:46 /var/run/docker.sock
coder@turquoise-muskox-97:/workspaces$ id
uid=1000(coder) gid=997(docker) groups=997(docker),0(root)
coder@turquoise-muskox-97:/workspaces$ ls -l /var/run/docker.sock
ls: cannot access '/var/run/docker.sock': Permission denied
coder@turquoise-muskox-97:/workspaces$ docker run hello-world
docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Head "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied

Run 'docker run --help' for more information
coder@turquoise-muskox-97:/workspaces$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

...

For more examples and ideas, visit:
https://docs.docker.com/get-started/

coder@turquoise-muskox-97:/workspaces$
4 Replies
Codercord
Codercord5d ago
<#1363698304277549127>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Phorcys
Phorcys4d ago
@pitcrew did you install the docker in docker devcontainer feature in your devcontainer spec? though given what you have already done, i doubt it'd do much more
pitcrew
pitcrewOP4d ago
I hadn't done that, I am actually just using the runtime = "sysbox-runc" argument in the .tf file. I'll try to add it just in case, I'll post a GitHub issue for this if I can't resolve it myself tomorrow, thank you!
Phorcys
Phorcys4d ago
have you done any other edits to the template? any edits to the image maybe?

Did you find this page helpful?