Docker-Compose 跳过本地守护进程的代理

Docker-Compose 跳过本地守护进程的代理

我正在运行安装在 Windows 上的 docker 引擎。我在 :2375 上公开了守护进程。

我在 WSL(“Windows 版 Bash”)上安装了 docker 和 docker-compose CLI。

我使用公司代理,在 docker 引擎 GUI 中,我设置了环境变量并将代理设置为绕过 127.0.0.1 和 localhost,一切似乎都运行正常。

但是,docker-compose 会导致代理错误。看来 docker-compose 正在联系我的公司代理来访问在 localhost 上运行的守护程序。如何解决这个问题?我已经在 docker 引擎排除配置中排除了 127.0.0.1 和 localhost。

ajohnson@232341-PC:~/concourse$ docker-compose --verbose ps
compose.config.config.find: Using configuration files: ./docker-compose.yml
docker.utils.config.find_config_file: Trying paths: ['/home/ajohnson/.docker/config.json', '/home/ajohnson/.dockercfg']
docker.utils.config.find_config_file: No config file found
docker.utils.config.find_config_file: Trying paths: ['/home/ajohnson/.docker/config.json', '/home/ajohnson/.dockercfg']
docker.utils.config.find_config_file: No config file found
urllib3.connectionpool._new_conn: Starting new HTTP connection (1): proxy.company.org:80
urllib3.connectionpool._make_request: http://proxy.company.org:80 "GET http://localhost:2375/v1.25/version HTTP/1.1" 504 3676
Traceback (most recent call last):
  File "/home/ajohnson/.local/bin/docker-compose", line 11, in <module>
    sys.exit(main())
  File "/home/ajohnson/.local/lib/python2.7/site-packages/compose/cli/main.py", line 71, in main
    command()
  File "/home/ajohnson/.local/lib/python2.7/site-packages/compose/cli/main.py", line 124, in perform_command
    project = project_from_options('.', options)
  File "/home/ajohnson/.local/lib/python2.7/site-packages/compose/cli/command.py", line 42, in project_from_options
    compatibility=options.get('--compatibility'),
  File "/home/ajohnson/.local/lib/python2.7/site-packages/compose/cli/command.py", line 123, in get_project
    host=host, environment=environment
  File "/home/ajohnson/.local/lib/python2.7/site-packages/compose/cli/command.py", line 97, in get_client
    version_info = six.iteritems(client.version())
  File "/home/ajohnson/.local/lib/python2.7/site-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
  File "/home/ajohnson/.local/lib/python2.7/site-packages/docker/api/client.py", line 267, in _result
    self._raise_for_status(response)
  File "/home/ajohnson/.local/lib/python2.7/site-packages/docker/api/client.py", line 263, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/home/ajohnson/.local/lib/python2.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 504 Server Error: Gateway Timeout ("<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Notification: Gateway Timeout</title>

“)

答案1

该问题已在这里解决: https://github.com/docker/compose/issues/6706

设置 NO_PROXY=localhost,127.0.0.* Compose 应该读取此变量,并且不使用公司代理来访问本地主机上的守护进程

相关内容