I’m trying to run Docker outside of Docker, so I’ve mounted the docker socket into a container that I start via
-v "/var/run/docker.sock:/var/run/docker.sock
From within the container I had a non-root user who is in the docker
group:
kurtis@container# groups kurtis
docker kurtis
However I can’t use docker:
kurtis@container# docker ps
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2F
run%2Fdocker.sock/v1.45/containers/json": dial unix /var/run/docker.sock: connect: permission denied
This is unsurprising, given that, from within the container, the socket appears to be owned by root
and the group is 134
(the id of the docker group on the host):
kurtis@container# ls -alh /var/run/docker.sock
srw-rw---- 1 root 134 0 Jul 3 15:24 /var/run/docker.sock
From within the container, if I do sudo chown root:docker /var/run/docker.sock
the group on the socket is changed on the host as well. That ends up breaking things because the id of the docker
group on the host is different from the id of the docker
group in the container.
Other than trying to make the id of the docker
group on both the host and the container match, is there a way to get sudo-less docker working from within a docker container?