docker - 在服务器中的 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/config.json
{ "proxies": { "default": { "httpProxy": "http://127.0.0.1:9278" } } }
尝试过
--env
论证尝试在服务器上设置代理变量但没有结果
我也试过这个链接
services: myservice: build: context: . args: - http_proxy - https_proxy - no_proxy
但我穿上这个
version: '3.6'
Unsupported config option for services.web: 'args'
这些设置似乎是在 docker 上设置的,而不是 docker-compose
我也不需要在我的本地设备上设置任何代理(如果可能的话,我不想失去可移植性)
docker-compose version 1.23.1, build b02f1306
Docker version 18.06.1-ce, build e68fc7a
解决方案
您必须来自 docker 禁止的受限制国家(来自403状态代码)。唯一的方法是在您的 docker 服务中使用代理。
[服务]
...
环境="HTTP_PROXY=http://proxy.example.com:80/ HTTPS_PROXY=http://proxy.example.com:80/"
...
之后你应该发出:
$ systemctl daemon-reload
$ systemctl restart docker
推荐阅读
- mysql - MySQL中两个日期之间的查询,按天数分组
- c - 在 C 中用 int 值更改字符串值
- javascript - execute a code after every 1/24 sec not working
- ios - IOS消息贴有声音
- python - 使用数据框中的列为 seaborn 图的背景着色
- ios - 在 iOS Swift 中对自定义对象进行排序
- elasticsearch - Flatten elastic search _source output
- spring - MQQueueConnectionFactory 和 MQXAQueueConnectionFactory 之间的区别
- blazor - 当用户在文本框(oninput)中输入时,如何调用异步方法?
- linux - 由于 SELINUX 无法使用 docker 缓存