首页 > 解决方案 > 在服务器中的 docker-compose 上使用代理

问题描述

当我跑步时,sudo docker-compose build我得到

Building web
Step 1/8 : FROM python:3.7-alpine
ERROR: Service 'web' failed to build: error parsing HTTP 403 response body: invalid character '<' looking for beginning of value: "<html><body><h1>403 Forbidden</h1>\nSince Docker is a US company, we must comply with US export control regulations. In an effort to comply with these, we now block all IP addresses that are located in Cuba, Iran, North Korea, Republic of Crimea, Sudan, and Syria. If you are not in one of these cities, countries, or regions and are blocked, please reach out to https://support.docker.com\n</body></html>\n\n"

我需要docker-compose为构建设置代理

我尝试过的事情:

查看https://docs.docker.com/network/proxy/#configure-the-docker-client

这些设置似乎是在 docker 上设置的,而不是 docker-compose

我也不需要在我的本地设备上设置任何代理(如果可能的话,我不想失去可移植性)

docker-compose version 1.23.1, build b02f1306
Docker version 18.06.1-ce, build e68fc7a

标签: dockerproxydocker-compose

解决方案


您必须来自 docker 禁止的受限制国家(来自403状态代码)。唯一的方法是在您的 docker 服务中使用代理。

[服务]

...

环境="HTTP_PROXY=http://proxy.example.com:80/ HTTPS_PROXY=http://proxy.example.com:80/"

...

之后你应该发出:

$ systemctl daemon-reload
$ systemctl restart docker

推荐阅读