Ped*_*o A 4 proxy gitlab docker gitlab-ci docker-in-docker
我正在尝试使用 gitlab CI 设置一项工作,以从 dockerfile 构建 docker 映像,但我位于代理后面。
我.gitlab-ci.yml的如下:
image: docker:stable
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
HTTP_PROXY: $http_proxy
HTTPS_PROXY: $http_proxy
http_proxy: $http_proxy
https_proxy: $http_proxy
services:
- docker:dind
before_script:
- wget -O - www.google.com # just to test
- docker search node # just to test
- docker info # just to test
build:
stage: build
script:
- docker build -t my-docker-image .
Run Code Online (Sandbox Code Playgroud)
wget有效,这意味着理论上代理设置是正确的
但命令docker search、docker info和docker build不起作用,显然是因为代理问题。
作业输出摘录:
$ docker search node
Warning: failed to get default registry endpoint from daemon (Error response from daemon:
[and here comes a huge raw HTML output including the following message: "504 - server did not respond to proxy"]
Run Code Online (Sandbox Code Playgroud)
看来 docker 不会从环境变量中读取来设置代理。
注意:我确实在 --privileged 模式下使用运行器,正如文档指示的那样。
我该如何解决?
小智 6
如果您希望能够在代理后面的 gitlab CI 中使用 docker-in-docker (dind),您还需要在 gitlab-ci.yml 文件中设置 no_proxy 变量。主机“docker”的 NO_PROXY。
这是与我的 dind 配合使用的 gitlab-ci.yml:
image: docker:19.03.12
variables:
DOCKER_TLS_CERTDIR: "/certs"
HTTPS_PROXY: "http://my_proxy:3128"
HTTP_PROXY: "http://my_proxy:3128"
NO_PROXY: "docker"
services:
- docker:19.03.12-dind
before_script:
- docker info
build:
stage: build
script:
- docker run hello-world
Run Code Online (Sandbox Code Playgroud)
祝你好运!
| 归档时间: |
|
| 查看次数: |
9777 次 |
| 最近记录: |