在服务器中的 docker-compose 上使用代理

2023-12-27

当我跑步时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"

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

我尝试过的事情:

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

  • 我尝试过设置~/.docker/config.json

    {
     "proxies":
     {
      "default":
      {
       "httpProxy": "http://127.0.0.1:9278"
      }
     }
    }
    
  • 尝试过--env争论

  • 尝试在服务器上设置代理变量但没有结果

  • 我也试过这个link https://stackoverflow.com/a/36084324/4626485

    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 https://httpstatuses.com/403状态码)。唯一的方法是在 docker 服务中使用代理。

[服务]

...

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

...

之后你应该发出:

$ systemctl daemon-reload
$ systemctl restart docker
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在服务器中的 docker-compose 上使用代理 的相关文章

随机推荐