3

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?
David Maze
  • 130,717
  • 29
  • 175
  • 215
ricko zoe
  • 496
  • 1
  • 6
  • 19

2 Answers2

4

just add --privileged to command.

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

Bukharov Sergey
  • 9,767
  • 5
  • 39
  • 54
  • 1
    Thanks. After I also find out more information about '--privileged' with gitlab-ci. I have to set privileged to true in the configuration file of my runner ~/.gitlab-runner/config.toml https://docs.gitlab.com/ce/ci/docker/using_docker_build.html – ricko zoe Mar 21 '18 at 10:04
  • 1
    Not sure how this answer is marked as correct. Still getting an error with this `$ docker run -it --rm --privileged --user dockremap docker:stable-dind docker ps error during connect: Get http://docker:2375/v1.40/containers/json: dial tcp: lookup docker on 194.168.4.100:53: no such host` – Bizmate May 18 '22 at 10:44
-2

I have found solution of same problem in this article https://www.santoshsrinivas.com/docker-on-ubuntu-16-04/

You need to run next commant on machine with your gitlab-ci worker

sudo groupadd docker
sudo gpasswd -a gitlab-runner docker
sudo service docker restart
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88