Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab Runner not running privileged

I have an issue with a GitLab Runner that has a service attached. Whenever the job is run, as soon as waiting for the service is completed, it gives me a warning:

ContainerStart: Error response from daemon: Cannot link to a non running container: /runner-b565e58e-project-4-concurrent-0-mysql-0 AS /runner-b565e58e-project-4-concurrent-0-mysql-0-wait-for-service/service

gitlab-ci.yml

stages:
  - test

test:
  stage: test
  image: primus852/gitlab:latest
  services:
    - name: mysql:latest
      command: ["cp tests/Files/db.sql /docker-entrypoint-initdb.d/"]
...

config.toml

[runners.docker]
    tls_verify = false
    image = "php:fpm-alpine"
    privileged = true
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock","/cache"]
    shm_size = 0
...

And the gitlab-runner is started with this:

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

So I guess something is wrong with the privileged stuff, but does anybody see what that may be?

like image 229
PrimuS Avatar asked Jun 05 '18 07:06

PrimuS


People also ask

What user does GitLab runner run as?

gitlab-ci. yml scripts are running as user gitlab-www now. If this one has same uid as host mounts, you are also able to deploy directly to host folders.

Do I need to install Docker for GitLab runner?

In general, the version of Docker Engine and the version of the GitLab Runner container image do not have to match. The GitLab Runner images should be backwards and forwards compatible. However, to ensure you have the latest features and security updates, you should always use the latest stable Docker Engine version.

How do I run Docker in privileged mode?

For a container to run as a privileged application, the user must “flag” it to enable all capabilities to the container or pod. In other words, when a container is in a privileged mode, you are giving the container all the capabilities that a host can perform.


1 Answers

you overwrite the service container command: ["mysqld"] with command: ["cp tests/Files/db.sql /docker-entrypoint-initdb.d/"], so the service container copies the files and stops after that, like you asked it to do.

so change to command: ["cp tests/Files/db.sql /docker-entrypoint-initdb.d/ & mysqld"] in order to start mysql after the cp-command

like image 178
Danny Avatar answered Oct 24 '22 22:10

Danny