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

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store