Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker-outside-of-docker does not work when running docker as a non-root user. #1005

Open
RaphaelMelanconAtBentley opened this issue Jun 18, 2024 · 4 comments

Comments

@RaphaelMelanconAtBentley

The feature attempts to mount /var/run/docker.sock, but when running docker as a non-root user as show in the docs, this is the wrong path to the socket...

@samruddhikhandale
Copy link
Member

Docker-outside-of-docker does not work when running docker as a non-root user

@RaphaelMelanconAtBentley When you say non-root user, are you talking about the dev container user or the Docker installed on your host machine?

@RaphaelMelanconAtBentley
Copy link
Author

The host docker is running as root, with a docker group to allow my host's user to use docker without sudo, as per Docker's documentation.

In the devcontainer, I am also using a non-root user, without sudo access.

From what I could find out yesterday, the GID of the host's docker group is different from the one created by the feature...

@alexcochran
Copy link

I might also be running into this problem. I have this feature on a dev container built on top of a custom Docker image that uses a non-root user and access to /var/run/docker.sock is denied. The docker group's GID in the container is 999, but 962 on my host machine; trying to figure out why

@jkuester
Copy link

jkuester commented Jul 30, 2024

I can confirm. This is also not working for me and it seems to be because of the docker group's GID. I was able to workaround this problem by wrapping my target image in a new Dockerfile that manually sets the GID of the docker group to match what is on my system:

Dockerfile:

FROM my_target_image

ARG dockerGid

USER root

RUN addgroup --gid $dockerGid docker \
    && usermod -aG docker local_user

# Reset user back to original non-root user from my_target_image
USER local_user 

devcontainer.json:

{
    "build": { 
        "dockerfile": "Dockerfile",
        "args": { "dockerGid": "998" } // Have to manually populate the GID of my host's docker group
    },
    "features": {
        "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants