Docker 在私有托管代理 (Azure DevOps) 上构建失败

Docker build failing on private hosted agent (Azure DevOps)

我正在尝试在私人托管的 Azure DevOps 代理上构建一个 docker 文件,该代理位于公司代理之后。基本图像是 python/3.8.3-slim-buster。当我 运行 apt-get update 我得到以下错误:

Err:1 http://deb.debian.org/debian buster InRelease
  470  status code 470 [IP: 151.101.36.204 80]
Err:2 http://security.debian.org/debian-security buster/updates InRelease
  470  status code 470 [IP: 151.101.36.204 80]
Err:3 http://deb.debian.org/debian buster-updates InRelease
  470  status code 470 [IP: 151.101.36.204 80]
Reading package lists...
E: The repository 'http://deb.debian.org/debian buster InRelease' is not signed.
E: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  470  status code 470 [IP: 151.101.36.204 80]
E: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  470  status code 470 [IP: 151.101.36.204 80]
E: The repository 'http://security.debian.org/debian-security buster/updates InRelease' is not signed.
E: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  470  status code 470 [IP: 151.101.36.204 80]
E: The repository 'http://deb.debian.org/debian buster-updates InRelease' is not signed.

现在棘手的部分是,如果我手动登录到这个代理,并在那里给出 docker 构建命令,它就可以正常工作。在 Microsoft 托管代理上构建也可以正常工作。

我将带有 --build-arg 标志的代理配置传递给 Dockerfile。

有人知道错误可能出在哪里吗?

编辑: 我尝试添加“--allow-releaseinfo-change”标志,仍然是同样的错误。我觉得它在某种程度上与代理相关,但不知道从哪里开始寻找。

今天我了解到 apt-get 将代理配置保存在其他地方,因为我的环境变量 HTTP_PROXY 和 HTTPS_PROXY 没有被选中。

创建一个 proxy.conf 并将其复制到容器解决了我的问题,如下所述: https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-the-proxy-for-apt-for-ubuntu-18-04/