1

I'm running a gitlab/gitlab-ce container on docker. Then , inside it, i want to run a gitlab-runner service, by providing docker as runner. And every single command that i run (e.g docker ps, docker container ..), i get this error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running

P.s: i've tried service docker restart, reinstal docker and gitlab-runner.

2
  • It seems that your docker daemon isnt started normally (which maybe caused by some errors such as cgroups), maybe you can read the docker daemon's log for trouble shooting~? Commented Dec 31, 2017 at 4:07
  • Why does your gitlab runner have to be in the same container as GitLab? This kind of goes against Docker practices. What would be better would be to run the runner in a separate container and then network the two containers together. Commented Jan 8, 2018 at 20:10

2 Answers 2

2

By default it is not possible to run docker-in-docker (as a security measure).

You can run your Gitlab container in privileged mode, mount the socket (-v /var/run/docker.sock://var/run/docker.sock) and try again.

Also, there is a docker-in-docker image that has been modified for docker-in-docker usage. You can read up on it here and create your own custom gitlab/gitlab-ce image.

In both cases, the end result will be the same as docker-in-docker isn't really docker-in-docker but lets your manage the hosts docker-engine from within a docker container. So just running the Gitlab-ci-runner docker image on the same host has the same result and is a lot easier.

Sign up to request clarification or add additional context in comments.

Comments

1

By default the docker container running gitlab does not have access to your docker daemon on your host. The docker client uses a socket connection to communicate to the docker daemon. This socket is not available in your container.

You can use a docker volume to make the socket of your host available in the container:

docker run -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-ce

Afterwards you will be able to use the docker client in your container to communicate with the docker daemon on the host.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.