docker 无法拉取基础镜像 |获取 https://registry-1.docker.io/v2/:

问题描述

我正在尝试使用我的构建管道构建一个 docker 镜像,但是 docker 无法拉取基本镜像 我的构建管道托管在 azure devops 服务器中 Windows Server 2019 VM 内托管的 Azure DevOps 服务器

2021-03-04T06:58:21.6816037Z ==============================================================================
2021-03-04T06:58:21.6816138Z Task         : Docker
2021-03-04T06:58:21.6816209Z Description  : Build,tag,push,or run Docker images,or run a Docker command. Task can be used with Docker or Azure Container registry.
2021-03-04T06:58:21.6816271Z Version      : 0.3.24
2021-03-04T06:58:21.6816322Z Author       : Microsoft Corporation
2021-03-04T06:58:21.6816387Z Help         : [More information](https://go.microsoft.com/fwlink/?linkid=848006)
2021-03-04T06:58:21.6816465Z ==============================================================================
2021-03-04T06:58:22.7477068Z [command]"C:\Program Files\Docker\docker.exe" build -f C:\myagent_agent\_work\7\s\hello-solution\core\Infrastructure\Docker\build\5910\Dockerfile -t myregistry.azurecr.io/myapp-hello:276 C:\heisoul2_agent\_work\7\s\hello-solution\core\Infrastructure\Docker\build\5910
2021-03-04T06:58:26.3591773Z Sending build context to Docker daemon  154.9MB
2021-03-04T06:58:26.3592364Z 
2021-03-04T06:58:26.3701800Z Step 1/19 : FROM tomcat:9.0.41-jdk15-openjdk-slim-buster
2021-03-04T06:58:41.7345125Z Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2021-03-04T06:58:41.7599411Z ##[error]C:\Program Files\Docker\docker.exe Failed with return code: 1
2021-03-04T06:58:41.7613038Z ##[section]Finishing: Build an image

Docker 桌面窗口平移未在资源部分显示选项

enter image description here

解决方法

由于目标不可达问题而遇到此错误。这意味着该端口可能被本地或外部防火墙过滤,可能是机器的 DNS 设置有问题。

但是在我的 docker 桌面窗口中,我看不到 非常奇怪的网络选项

对于此问题,网络选项卡在 Windows 容器模式下不可用,因为网络由 Windows 管理。这在官方document中有说明。

有关更改 Windows DNS 地址的详细说明here(请参阅第 II 部分)。

document 是关于配置容器 DNS,本节中的信息说明在 Docker 默认 bridge 中配置容器 DNS。

这里有一些票证(ticket1ticket2),您可以参考相同的问题。

,

我在 azure-pipeline.yml 的 dockertask 中使用了 buildArguments

buildArguments: 'http_proxy=http://username:password@proxy:80'