由于增加了流水线的构建时间,我们尝试了几种方法来改进它。需要花费相当多时间的一个步骤是按顺序运行的docker图像推送步骤。对于12张图片,这一步需要12-14分钟,我们决定尝试并行推送图片(考虑到这将花费12-14分钟到2-4分钟)。
在发布图像阶段下尝试了多个步骤,但失败了。
- name: Publish images
steps:
- publishImageConfig:
dockerfilePath: ./frontend/deployment/Dockerfile
buildContext: ./frontend
tag: registry.remote.com/remote/frontend-${CICD_EXECUTION_ID}
pushRemote: true
registry: registry.remote.com
- publishImageConfig:
dockerfilePath: ./gateway/backend/src/Dockerfile
buildContext: ./gateway/backend
tag: registry.remote.com/remote/backend-${CICD_EXECUTION_ID}
pushRemote: true
registry: registry.remote.com
[...]推送一个镜像,但使用Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?推送所有其他镜像都会失败
我还尝试从/etc/docker/daemon.json增加--max-concurrent-uploads,但没有成功。
发布于 2020-01-21 17:23:17
Docker的/var/lib/docker只能由单个守护进程管理。如果你想发布多个,有一个变通的方法。尝试如下所示:
stages:
- name: Publish images_1
steps:
- publishImageConfig:
dockerfilePath: ./frontend/deployment/Dockerfile
buildContext: ./frontend
tag: registry.remote.com/remote/frontend-${CICD_EXECUTION_ID}
pushRemote: true
registry: registry.remote.com
- name: Publish images_2
steps:
- publishImageConfig:
dockerfilePath: ./gateway/backend/src/Dockerfile
buildContext: ./gateway/backend
tag: registry.remote.com/remote/backend-${CICD_EXECUTION_ID}
pushRemote: true
registry: registry.remote.com
env:
PLUGIN_STORAGE_PATH: /var/lib/docker_2
[...]这个错误已经在this thread上报告了,你可以在那里找到更多信息。这个问题应该在牧场v2.2中修复,但一些人仍然在v2.3中遇到这个问题。但是,解决方法仍然有效。
我将这个答案作为社区维基发布,因为修复不是我最初的想法。
如果有帮助,请让我知道。
https://stackoverflow.com/questions/59782729
复制相似问题