4

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 --env argument

  • tried 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_proxy
    

    but 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
Amir Heshmati
  • 550
  • 1
  • 8
  • 19

4 Answers4

7

You must be from restricted countries which are banned by docker (from 403 status code). only way is to use proxies in your docker service.

[Service]

...

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

...

after that you should issue:

$ systemctl daemon-reload
$ systemctl restart docker
CallMeLoki
  • 1,281
  • 10
  • 23
1

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'
Vallabha Vamaravelli
  • 1,153
  • 1
  • 9
  • 15
0

1: edit resolve.conf in linux, add ip to the top of line in resolv.conf

nameserver {type ip}

2: use a poxy and create an account in docker hub (https://hub.docker.com/)

3:login into docker

sudo docker login
user:
password:

4: if you have problem try step 3 again

Mohammad Yaser Ahmadi
  • 4,664
  • 3
  • 17
  • 39
0

You need to make an env file which you put proxy settings in /usr/local/etc/myproxy.env

HTTP_PROXY=http://proxy.mydomain.net:3128
HTTPS_PROXY=http://proxy.mydomain.net:3128

Then run docker-compose with something like:

docker-compose -f /opt/docker-compose.yml --env-file /usr/local/etc/myproxy.env up
TS L
  • 1