GitLab CI: Docker in Docker (DinD) on gitlab.com Shared Runners

--

How to run DinD jobs on gitlab.com Shared Runners

This post is also available on my blog.

Gitlab provides shared runners for the repositories that are hosted on gitlab.com: https://docs.gitlab.com/ee/ci/runners/README.html#shared-runners

You can run Docker commands inside a job by

  • selecting a runner that has the docker capability (tags: docker )
  • using the docker image for the job (image: docker:latest )
  • registering a docker:dind service (services: docker:dind )

An example running a container that says hello:

stages:
- Say Hello

hello-world:
stage: Say Hello
tags:
- docker
image: docker:latest
services:
- docker:dind
script:
- docker run --rm hello-world:latest
GitLab CI pipeline output

--

--

Orlando Thöny

PHP Software & DevOps Engineer. Moved to https://thoeny.dev