问题
When i run sudo docker-compose build i get
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"
I need to set proxy for docker-compose for build
things i have tried:
looking at https://docs.docker.com/network/proxy/#configure-the-docker-client
i have tried setting
~/.docker/config.json{ "proxies": { "default": { "httpProxy": "http://127.0.0.1:9278" } } }tried with
--envargumenttried setting proxy variables on the server with no result
i also have tried this link
services: myservice: build: context: . args: - http_proxy - https_proxy - no_proxybut i get this on
version: '3.6'Unsupported config option for services.web: 'args'
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
回答1:
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/"
after that you should issu:
$ systemctl daemon-reload
$ systemctl restart docker
回答2:
Include proxy details for each service in docker-compose.yml file, the sample configuration looks as below mentioned. Restart the docker and then run "docker-compose build" again. You might also run "docker-compose ps" to see if all the services mentioned in the compose file running successfully.
services:
<service_name>:
image:
hostname:
container_name:
ports:
environment:
HTTP_PROXY: 'http://host:port'
HTTPS_PROXY: 'http://host:port'
NO_PROXY: 'localhost, *.test.lan'
来源:https://stackoverflow.com/questions/53477114/using-proxy-on-docker-compose-in-server