Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab-CI multi runner start docker container

I still don't quite understand the process for a gitlab-ci multi runner to start a docker and interact inside with the code.

Is it possible for a gitlab-ci multi runner to start a docker container having the current code inside this docker container and then run tests against this code? (e.g.: code linting)

I basically want a docker container that has various linters installed. GitLab-CI multi runner should run on the host system and start the docker container on-demand. Inside the docker container, the code should be checked against phpcs for example.

How do I get the repo code into the docker container?

Thanks for the help

like image 829
lockdoc Avatar asked Jul 30 '15 10:07

lockdoc


People also ask

Is Docker required for GitLab runner?

To use GitLab Runner with Docker you need to register a runner that uses the Docker executor. The registered runner uses the ruby:2.6 Docker image and runs two services, postgres:latest and mysql:latest , both of which are accessible during the build process.

Does GitLab CI use Docker?

You can use GitLab CI/CD with Docker to create Docker images. For example, you can create a Docker image of your application, test it, and publish it to a container registry. To run Docker commands in your CI/CD jobs, you must configure GitLab Runner to support docker commands.


1 Answers

First, gitlab-runner needs to have the Docker socket mounted as described in the documentation:

docker run -d --name gitlab-runner --restart always \
 -v /var/run/docker.sock:/var/run/docker.sock \
 -v /srv/gitlab-runner/config:/etc/gitlab-runner \
 gitlab/gitlab-runner:latest

Afterwards, you have to register the runner with:

  1. docker as executor.
  2. the Docker image with the linters you want as Docker image.
like image 121
JoKo Avatar answered Oct 17 '22 01:10

JoKo