Gitlab准备失败:来自守护进程的错误响应:冲突。容器名称已被容器使用

Gitlab准备失败:来自守护进程的错误响应:冲突。容器名称已被容器使用,gitlab,gitlab-ci,gitlab-ci-runner,Gitlab,Gitlab Ci,Gitlab Ci Runner,我正在使用Gitlab CI进行持续集成开发。我让我的gitlab运行程序在ubuntu实例上运行 我有一个应用程序,使用MongoDB v3.6。我必须在CI/CD的测试阶段进行数据库集成测试 prepare: image: node:11.10.1-alpine stage: setup script: - npm install --quiet node-gyp - npm install --quiet - npm install -g y

我正在使用Gitlab CI进行持续集成开发。我让我的gitlab运行程序在ubuntu实例上运行

我有一个应用程序,使用MongoDB v3.6。我必须在CI/CD的测试阶段进行数据库集成测试

prepare:
    image: node:11.10.1-alpine
    stage: setup
    script:
    - npm install --quiet node-gyp
    - npm install --quiet
    - npm install -g yarn
    - chmod a+rwx  /usr/local/lib/node_modules/yarn/bin/yarn*
    - chmod a+rwx  /usr/local/bin/yarn*
    - yarn install
    - cd client
    - yarn install
    - cd ../
    - cd admin
    - yarn install
    cache:
        key: "$CI_COMMIT_REF_SLUG"
        paths:
        - node_modules/
        - client/node_modules/
        - admin/node_modules/
        policy: push

app_testing:
    image: node:11.10.1-alpine
    services:
    - name: mongo:3.6
    stage: test
    cache:
        key: "$CI_COMMIT_REF_SLUG"
        paths:
        - node_modules/
        - client/node_modules/
        - admin/node_modules/
    script:
    - yarn run test
    - cd client
    - yarn run test
    - cd ../
    - cd admin
    - yarn run test
对于每个备用管道,我在应用程序测试(测试)阶段得到以下错误

ERROR: Job failed (system failure): Error response from daemon: Conflict. The container name "/runner-e7ce6426-project-11081252-concurrent-0-mongo-0" is already in use by container "0964b061b56d8995966f577e7354852130915228bac1a7513a773bbb82aeefaf". You have to remove (or rename) that container to be able to reuse that name.
下面是失败的特定作业的完整日志

Running with gitlab-runner 10.8.0 (079aad9e)
  on SharedRunner-XYZGroup e7ce6426
Using Docker executor with image node:11.10.1-alpine ...
Starting service mongo:3.6 ...
Pulling docker image mongo:3.6 ...
Using docker image sha256:57c2f7e051086c7618c26a2998afb689214b4213edd578f82fe4b2b1d19ee7c0 for mongo:3.6 ...
ERROR: Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Will be retried in 3s ...
Using Docker executor with image node:11.10.1-alpine ...
Starting service mongo:3.6 ...
Pulling docker image mongo:3.6 ...
Using docker image sha256:57c2f7e051086c7618c26a2998afb689214b4213edd578f82fe4b2b1d19ee7c0 for mongo:3.6 ...
ERROR: Preparation failed: Error response from daemon: Conflict. The container name "/runner-e7ce6426-project-11081252-concurrent-0-mongo-0" is already in use by container "0964b061b56d8995966f577e7354852130915228bac1a7513a773bbb82aeefaf". You have to remove (or rename) that container to be able to reuse that name.
Will be retried in 3s ...
Using Docker executor with image node:11.10.1-alpine ...
Starting service mongo:3.6 ...
Pulling docker image mongo:3.6 ...
Using docker image sha256:57c2f7e051086c7618c26a2998afb689214b4213edd578f82fe4b2b1d19ee7c0 for mongo:3.6 ...
ERROR: Preparation failed: Error response from daemon: Conflict. The container name "/runner-e7ce6426-project-11081252-concurrent-0-mongo-0" is already in use by container "0964b061b56d8995966f577e7354852130915228bac1a7513a773bbb82aeefaf". You have to remove (or rename) that container to be able to reuse that name.
Will be retried in 3s ...
ERROR: Job failed (system failure): Error response from daemon: Conflict. The container name "/runner-e7ce6426-project-11081252-concurrent-0-mongo-0" is already in use by container "0964b061b56d8995966f577e7354852130915228bac1a7513a773bbb82aeefaf". You have to remove (or rename) that container to be able to reuse that name.
我尝试禁用辅助缓存,但对我无效

现在我不知道如何解决这个问题。作为一种解决方法,我必须在每次失败时触发一个新的管道,这当然没有人喜欢,因为任何人自动化事情的最终目标都是专注于最重要的事情

在此方面的任何帮助都将不胜感激


提前感谢。

这是一个已知问题,请参阅。GitLab正在重新使用相同的服务容器名称。如果没有及时删除上一个容器,此方法将失败

如果您通读(一长串)评论,您可能会发现一些解决方法,其中包括:

  • 将并发限制为1
  • 提高跑步者机器的IOPS(例如,从HDD切换到SSD)

由于我们在Docker executor上遇到了同样的问题,我们目前使用Docker+机器执行器解决了这个问题。虽然您不能真正确保避免这个错误,但我的经验是,从那时起,作业运行更加可靠。然而,折衷的办法是,为每个作业提供一个想要付费的虚拟机。

这是一个已知的问题,请参阅。GitLab正在重新使用相同的服务容器名称。如果没有及时删除上一个容器,此方法将失败

如果您通读(一长串)评论,您可能会发现一些解决方法,其中包括:

  • 将并发限制为1
  • 提高跑步者机器的IOPS(例如,从HDD切换到SSD)

由于我们在Docker executor上遇到了同样的问题,我们目前使用Docker+机器执行器解决了这个问题。虽然您不能真正确保避免这个错误,但我的经验是,从那时起,作业运行更加可靠。然而,折衷的办法是,为每个作业提供一个希望获得报酬的虚拟机。

谢谢Marcel。我浪费了将近一天的时间试图使用gitlab runner的runners.docker配置中的disable_cache来修复这个问题。我甚至试图修改我的代码,认为这可能是某种代码问题。现在我的并发限制为1,我正在使用SSD,但不确定SSD应该有多快。我正在使用Azure云。我仍然有这个问题。有趣的是,我们也使用Azure。我已经更新了我的答案,并添加了一些关于我们当前Docker+机器执行器“变通方法”的信息。感谢更新变通方法。我的公司不让我付任何额外费用。不过我有一个简单的解决方法,一旦失败就点击“重试作业”。这将解决我的问题,但就像我每次提交代码时都要做的一样。谢谢你Marcel。我浪费了将近一天的时间试图使用gitlab runner的runners.docker配置中的disable_cache来修复这个问题。我甚至试图修改我的代码,认为这可能是某种代码问题。现在我的并发限制为1,我正在使用SSD,但不确定SSD应该有多快。我正在使用Azure云。我仍然有这个问题。有趣的是,我们也使用Azure。我已经更新了我的答案,并添加了一些关于我们当前Docker+机器执行器“变通方法”的信息。感谢更新变通方法。我的公司不让我付任何额外费用。不过我有一个简单的解决方法,一旦失败就点击“重试作业”。这将解决我的问题,但就像每次提交代码时我都必须这样做一样。