Use gitlab-runner and dind (Docker-in-Docker) on MacOS

What I learned today — 30 September 2018

Niel de Wet
1 min readSep 30, 2018

Install:

To test your .gitlab-ci.yml locally on MacOS (I’m using High Sierra) you need the following:

After installing Docker, install the runner using brew:

brew install gitlab-ci-multi-runner

Set up .gitlab-ci.yaml:

Your CI file might look something like this:

image: docker:latest
services:
- docker:dind

variables:
DOCKER_DRIVER: overlay

stages:
- build

docker-build:
stage: build
script:
- docker build -t registry.gitlab.com/my-username/my-project .
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker push registry.gitlab.com/my-username/my-project

Run locally before pushing:

gitlab-runner exec docker --docker-privileged docker-build

Let’s unpack the above:

  • exec Test your .gitlab-ci.yml locally using the “exec” command
  • docker Use the “docker” executor
  • --docker-privileged Running dind (“Docker-in-docker”) requires the “privileged” flag

--

--

Responses (1)