Gitlab runner in Docker container

Docker container creation

Create container with configuration:

$ docker volume create --name gitlab-runner-config

Create gitlab runner:

$ docker run -d --name gitlab-runner --restart always \
  -v gitlab-runner-config:/etc/gitlab-runner \
   gitlab/gitlab-runner:latest

Register the runner:

$ docker exec -it gitlab-runner gitlab-runner register \
  --non-interactive \
  --url "https://git.startext.ru:5000/ci" \
  --registration-token "TOKEN_HERE" \
  --name "runner-name" \
  --executor "shell" \
  --tag-list "java,gradle,nodejs"
INFO[0000] TN4Lx9Wp Registering runner... succeeded
INFO[0000] Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

The runner should is started already and you are ready to build your projects!

Check version

$ docker exec -ti gitlab-runner gitlab-runner -v

Update container

Pull the latest version:

$ docker pull gitlab/gitlab-runner:latest

Stop and remove the existing container:

$ docker stop gitlab-runner && docker rm gitlab-runner

Start the container as we did it before:

$ docker run -d --name gitlab-runner --restart always \
  -v gitlab-runner-config:/etc/gitlab-runner \
   gitlab/gitlab-runner:latest

See also Gitlab runner in Docker container with gradle environment article.