由于增加了管道的构建时间,因此我们尝试了几项改进。花费大量时间的一个步骤是按顺序运行的docker images push步骤。由于是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?
失败
我还尝试将--max-concurrent-uploads
的{{1}}增加到没有成功的地方。
答案 0 :(得分:1)
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中报告,您可以在此处找到更多信息。
该问题本应在Rancher v2.2
中解决,但有些人仍然在v2.3
中遇到此问题。
但是,该解决方法仍然有效。
我将此答案发布为社区Wiki,因为此修复不是我的初衷。
请告诉我是否有帮助。