我有Harbor
个本地Docker注册表,所有必需的映像都已存在,并将GitLab连接到了Harbour,并且所有图像都是从Harbour接收的,但是11月2日之后,Docker限制了拉取次数,因此似乎服务是从Docker集线器中提取的。
是否可以使用Dind服务从Harbour撤出?
管道输出:
Running with gitlab-runner 12.10.1 (ce065b93)
on docker_runner_7 WykGNjC6
Preparing the "docker" executor
30:20
Using Docker executor with image **harbor**.XXX.XXXX.net/library/docker_maven_jvm14 ...
Starting service docker:**dind** ...
**Pulling docker image docker:dind** ...
**ERROR**: Preparation failed: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit (docker.go:198:2s)
Will be retried in 3s ...
Using Docker executor with image harbor.XXX.XXX.net/library/docker_maven_jvm14 ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
ERROR: Preparation failed: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit (docker.go:198:4s)
Will be retried in 3s ...
Using Docker executor with image harbor.XXX.XXX.net/library/docker_maven_jvm14 ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
ERROR: Preparation failed: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit (docker.go:198:3s)
Will be retried in 3s ...
ERROR: Job failed (system failure): Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit (docker.go:198:3s)
答案 0 :(得分:2)
另一种方式:
如果您不想添加daemon.json
,则可以执行以下操作:
docker pull docker:stable-dind
docker login harbor.XXX.com
docker tag docker:stable-dind harbor.XXX.com/library/docker:stable-dind
docker push harbor.XXX.com/library/docker:stable-dind
转到.gitlab-ci.yml
代替
services:
- docker:dind
写:
services:
- name: harbor.XXX.com/library/docker:stable-dind
alias: docker
我的.gitlab-ci.yml
:
stages:
- build_and_push
Build:
image: ${DOCKER_REGISTRY}/library/docker:ci_tools
stage: build_and_push
tags:
- dind
services:
- name: ${DOCKER_REGISTRY}/library/docker:stable-dind
alias: docker
script:
- docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY
- make build test release REGISTRY=${DOCKER_REGISTRY}/library/ TELEGRAF_DOWNLOAD_URL="https://storage.XXX.com/ops/packages/telegraf-1.15.3_linux_amd64.tar.gz" TELEGRAF_SHA256="85a1ee372fb06921d09a345641bba5f3488d2db59a3fafa06f3f8c876523801d"
答案 1 :(得分:1)
我找不到适用于Gitlab的解决方案,但是您可以告诉docker忽略docker hub注册表并转到本地注册表。
在daemon.json
中添加/etc/docker/daemon.json
,如果不存在,则只需添加路径即可。
daemon.json
{
"registry-mirrors": ["https://harbor.XXX.com"]
}
sudo systemctl重新启动docker
答案 2 :(得分:0)
我在将一些微服务部署到 kube 集群时也遇到了同样的问题,这是我写的一篇博客,提供了一种优化部署工作流程的解决方法:https://mailazy.com/blog/optimize-docker-pull-gitlab-pipelines/