瀏覽代碼

Allow API version specification via env var

Hard-coding the API version to '1.18' with the docker-py constructor will
cause the docker-py logic at
https://github.com/docker/docker-py/blob/master/docker/client.py#L143-L146
to always fail, which will cause authentication issues if you're using a
remote daemon using API version 1.19 - regardless of the API version of
the registry.

Allow the user to set the API version via an environment variable. If
the variable is not present, it will still default to '1.18' like it
does today.

Signed-off-by: Reilly Herrewig-Pope <[email protected]>
Reilly Herrewig-Pope 10 年之前
父節點
當前提交
fc203d643a
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      compose/cli/docker_client.py

+ 3 - 1
compose/cli/docker_client.py

@@ -14,6 +14,8 @@ def docker_client():
         cert_path = os.path.join(os.environ.get('HOME', ''), '.docker')
 
     base_url = os.environ.get('DOCKER_HOST')
+    api_version = os.environ.get('COMPOSE_API_VERSION', '1.18')
+
     tls_config = None
 
     if os.environ.get('DOCKER_TLS_VERIFY', '') != '':
@@ -32,4 +34,4 @@ def docker_client():
         )
 
     timeout = int(os.environ.get('DOCKER_CLIENT_TIMEOUT', 60))
-    return Client(base_url=base_url, tls=tls_config, version='1.18', timeout=timeout)
+    return Client(base_url=base_url, tls=tls_config, version=api_version, timeout=timeout)