为什么几天后我的 gitlab-runner(在 Docker 容器中)失败了,我没有做任何改变

Why fails my gitlab-runner (in Docker Container) since a few days, I didn't change anything

我有一个 Ubuntu 18.04 服务器。在此服务器上 运行 docker 容器中的 gitlab-ce 12.7.5 实例和 docker 容器中的 gitlab-runner 12.8.0 实例。几天以来,所有管道都失败了:

*Running with gitlab-runner 12.8.0 (1b659122)
  on ddddd kbuTsA6j
Using Docker executor with image ubuntu:18.04 ...
00:02
Pulling docker image ubuntu:18.04 ...
Using docker image sha256:2c047404e52d7f17bdac4121a13cd844447b74e13063f8cb8f8b314467feed06 for ubuntu:18.04 ...
ERROR: Job failed (system failure): Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: process_linux.go:422: setting cgroup config for procHooks process caused: resulting devices cgroup doesn't match target mode: unknown (executor_docker.go:810:0s)*

gitlab-runner容器的config.toml文件是这样的:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "ddddd"
  url = "https://myreplacedname.stratoserver.net:8929/"
  token = "kbuTsA6jgE_GrM"
  tls-ca-file = "/etc/gitlab-runner/certs/myreplacedname.stratoserver.net.crt"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = "docker:19.03.1"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/srv/gitlab-runner/config:/etc/gitlab-runner", "/cache", "/builds:/builds"]
    shm_size = 0

直到几天前,一切正常。如果你能帮助我,我会很高兴。谢谢!

我花了几天时间试图找到解决同一问题的方法。我发现将值 false 分配给 [runners.docker] 部分的 privileged 字段可以解决这个问题。

因此,在您的情况下,生成的配置将如下所示:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "ddddd"
  url = "https://myreplacedname.stratoserver.net:8929/"
  token = "kbuTsA6jgE_GrM"
  tls-ca-file = "/etc/gitlab-runner/certs/myreplacedname.stratoserver.net.crt"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = "docker:19.03.1"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/srv/gitlab-runner/config:/etc/gitlab-runner", "/cache", "/builds:/builds"]
    shm_size = 0

当然,要应用这些更改,您必须在执行这些操作后重新启动 gitlab-runner 实例。希望对你也有帮助。