Home Use Docker DIND in gitlab actions
Post
Cancel

Use Docker DIND in gitlab actions

So this will be a short blog post just to explain a bit further on how docker DIND can work within gitlab actions.

One tiny piece to get it to work

So if you ever tried to build your docker images with a pipeline possibly you have found some errors that it can’t connect to docker. Well this is correct since an container normally cannot connect to it. What can you then do to make it work? Well actually it is pretty easy!

First of all I won’t go through installing gitlab runner or adding it to a project and so on but lets keep it simple. There is 1 trick to make it work and that is to make sure the following is in the /etc/gitlab-runner/config.toml

1
volumes = ["/var/run/docker.sock:/var/run/docker.sock","/cache"]

That way the container can reach the docker socket.

A word of advice

Always think about security! With this the docker container can do more then it would normally do. Isolate the runner maybe and of course: Monitor it!

And that was all

Well it was pretty short but that was all =) took me a while to figure it out a bit but hopefully it helps somebody!

This post is licensed under CC BY 4.0 by the author.