6

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?

PrimuS
  • 2,505
  • 6
  • 33
  • 66

1 Answers1

3

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

Danny
  • 1,603
  • 1
  • 15
  • 25