Search code examples
dockergitlab-cidocker-in-docker

Docker dind : Cannot connect to the Docker daemon


While running docker:dind I can't use docker login command and any other docker command.

My use case is that I got a Nexus Docker Registry and I'm trying to connect to this registry through GitLab CI.

docker run --rm -it docker:stable-dind docker login -u user -p password https://registry.mine.io

Give:

Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Solution

  • just add --privileged to command.

    docker run --rm -it --privileged docker:stable-dind docker login -u user -p password https://registry.mine.io