Docker in docker devcontainer feature cannot connect to Docker daemon

Anyone successfully using docker in docker feature with devcontainers in VSCode? I get the following on both 41.20250105 and 41.20241215 when I use the docker ps command inside a devcontainer:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

It might be kernel related per the issue below, but I’ve rolled back to 41.20241215 (kernel 6.11.6-300) which doesn’t appear to resolve the problem.

I’m facing the same issue on 41.20250126.1

I tried mounting the Docker socket with

"mounts": [
		{
			"source": "/var/run/docker.sock",
			"target": "/var/run/docker.sock",
			"type": "bind"
		}
	]

Then, the reported error is

Error: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: 
dial unix /var/run/docker.sock: connect: permission denied

Within my devcontainer the user id looks like:

> id
uid=1000(node) gid=1000(node) groups=1000(node),102(docker),997(pipx),998(nvm),999(npm)

> whoami
node

I have the same issue. To get around it I used docker-outside-docker instead of docker-in-docker.

It doesn’t solve it, but it gets you unstuck.

features/src/docker-outside-of-docker at main · devcontainers/features

1 Like

Same issue on 41.20250216.1.

Hmmm, for docker-in-docker, are we supposed to manually start the docker daemon within a devcontainer? Ran ‘sudo service docker start’ within the container and it works for my use cases.

Docker outside of docker also works nicely.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.