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)

  • Docker: execute a program that requires tty
  • docker0 interface missing on osx
  • How to see docker image contents
  • How to download Docker images without a direct internet connection
  • Unable to start docker service with error “Failed to start docker.service: Unit not found.”
  • How to run redmine with a postgresql database using docker compose
  • 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

  • How does the Docker assign MAC addresses to containers?
  • Creating a running Postgres service inside a docker container
  • Fail2ban filter for docker sshd container using syslog
  • cannot mount windows directory
  • What is wrong in my docker-compose.yml file?
  • my docker build just keeps closing
  • 2 Solutions collect form web for “GitLab-CI multi runner start docker container”

    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.

    Every docker client will forward the commands to the docker daemon,the docker daemon will listen to the local port such as http,tcp or unix socket.

    When you start container like this:

    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

    All the docker commands will forward to the host,as the docker was listening on unix:///var/run/docker.sock

    PS: You nedd to install docker in the gitlab-runnercontainer

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.