在服务器上的docker-compose上使用代理 [英] Using proxy on docker-compose in server
问题描述
当我运行 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
设置代理以构建
I need to set proxy for docker-compose
for build
我尝试过的事情:
查看 https ://docs.docker.com/network/proxy/#configure-the-docker-client
-
我尝试设置
〜/ .docker / config.json
{
"proxies":
{
"default":
{
"httpProxy": "http://127.0.0.1:9278"
}
}
}
尝试过 --env
参数
尝试在服务器上设置代理变量,但没有结果
tried setting proxy variables on the server with no result
我也尝试过此链接
services:
myservice:
build:
context: .
args:
- http_proxy
- https_proxy
- no_proxy
但是我在 version上得到了这个:'3.6'
Unsupported config option for services.web: 'args'
这些设置似乎是在docker上设置的,而不是在docker-compose
these settings seem to be set on docker and not docker-compose
我也不需要在我的本地设备上设置任何代理(我不想
i also don't need to set any proxy on my local device (i don't want to loose portability if possible)
docker-compose version 1.23.1, build b02f1306
Docker version 18.06.1-ce, build e68fc7a
推荐答案
您必须来自伊朗被docker禁止(来自 403 状态代码)。通过编辑``:
You must be from Iran which is banned by docker (from 403 status code). add http proxy env to you docker service by editing ``:
[Service]
Environment = HTTP_PROXY = http:// proxy.example.com:80/ HTTPS_PROXY = http://proxy.example.com:80 /
之后,您应该发出:
$ systemctl daemon-reload
$ systemctl restart docker
这篇关于在服务器上的docker-compose上使用代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!