I'm running a container that is configured to run with a non-root user. In this container I want to be able to run the docker CLI to access the docker daemon on the host. My host machine is Windows with Docker Desktop integrated with WSL.
Here's my Dockerfile:
FROM alpine
RUN apk add docker-cli shadow
RUN adduser --disabled-password app
RUN addgroup docker
RUN usermod -aG docker app
USER app
I run the container with this command:
> docker run --rm -v /var/run/docker.sock:/var/run/docker.sock test docker info
That gives me this output and error:
Client:
Context: default
Debug Mode: false
Server:
ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": dial unix /var/run/docker.sock: connect: permission denied
errors pretty printing info
If I use the --user root option, the command succeeds. But I'm trying to figure out a way to get this to work with the non-root user.
I know from researching this issue that the user ID needs to match up with what's available on the host (see Run docker inside docker as non root user). But I can't figure out how to configure the host and how to get the user ID info since the daemon is running through WSL.