Skip to main content

Brain Dump

Run Gitlab CI Locally

This post explains how to run gitlab-ci.yml configuration in your local workstation.


  • Ubuntu 20.04
  • Docker v20
  • Git repo (Note: uncommitted changes (except for gitlab-ci.yml) will not be included by the runner)
  • gitlab-ci.yml file

Minimal sample for gitlab-ci.yml:

image: python:3.8-slim

  - python --version
  - pip list
  - ls -lha

    - echo "hello world"


# Go into your repo root
cd my_repo

# Mount your repo in one terminal
docker run --rm --name gitlab-runner \
    -v $PWD:$PWD -v /var/run/docker.sock:/var/run/docker.sock \

# Run the gitlab-runner on another terminal
docker exec -it -w $PWD gitlab-runner gitlab-runner exec docker test

The repo mounter container can be sent to the background, by adding -d flag. But I always forget to kill it, and I do not like having unused process running in the background, especially with the exposed Unix socket.

So I keep it running on the foreground, and Ctrl-C it when I am done.