Gitlab 准备失败:来自守护程序的错误响应:冲突。容器名称已被容器使用
Gitlab Preparation failed: Error response from daemon: Conflict. The container name is already in use by container
我在开发中使用 Gitlab CI 进行持续集成。我的 gitlab-runner 在 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
对于每个备用管道,我在 app_testing(测试)阶段 中收到以下 错误。
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.
我试过禁用二级缓存,它对我不起作用。
现在我不知道如何解决这个问题。作为一种解决方法,每次失败时我都必须触发一个新的管道,这当然没有人喜欢,因为任何人自动化的最终目标都是专注于最重要的事情。
如有任何帮助,我们将不胜感激。
提前致谢。
这是一个已知问题,请参阅 https://gitlab.com/gitlab-org/gitlab-runner/issues/4327。 GitLab 正在重新使用相同的服务容器名称。如果之前的容器没有及时删除,这种方法就会失败。
如果您通读(一长串)评论,您可能会发现一些解决方法,其中包括:
- 将并发数限制为 1
- 增加 Runner 机器的 IOPS(例如,从 HDD 切换到 SSD)
由于我们在 Docker 执行器上遇到了同样的问题,我们目前通过使用 Docker+Machine 执行器来解决它。虽然你不能真正确定避免该错误,但我的经验是,从那以后,工作 运行 更可靠。然而,需要权衡的是,对于每项工作,都会配置一个需要付费的 VM。
我在开发中使用 Gitlab CI 进行持续集成。我的 gitlab-runner 在 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
对于每个备用管道,我在 app_testing(测试)阶段 中收到以下 错误。
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.
我试过禁用二级缓存,它对我不起作用。
现在我不知道如何解决这个问题。作为一种解决方法,每次失败时我都必须触发一个新的管道,这当然没有人喜欢,因为任何人自动化的最终目标都是专注于最重要的事情。
如有任何帮助,我们将不胜感激。
提前致谢。
这是一个已知问题,请参阅 https://gitlab.com/gitlab-org/gitlab-runner/issues/4327。 GitLab 正在重新使用相同的服务容器名称。如果之前的容器没有及时删除,这种方法就会失败。
如果您通读(一长串)评论,您可能会发现一些解决方法,其中包括:
- 将并发数限制为 1
- 增加 Runner 机器的 IOPS(例如,从 HDD 切换到 SSD)
由于我们在 Docker 执行器上遇到了同样的问题,我们目前通过使用 Docker+Machine 执行器来解决它。虽然你不能真正确定避免该错误,但我的经验是,从那以后,工作 运行 更可靠。然而,需要权衡的是,对于每项工作,都会配置一个需要付费的 VM。