Merge pull request #2692 from aanand/fix-tls-paramater-error

Catch TLSParameterErrors from docker-py
This commit is contained in:
Aanand Prasad 2016-01-19 11:25:21 +00:00
commit 5b2b4cbb07
1 changed files with 11 additions and 1 deletions

View File

@ -5,9 +5,11 @@ import logging
import os
from docker import Client
from docker.errors import TLSParameterError
from docker.utils import kwargs_from_env
from ..const import HTTP_TIMEOUT
from .errors import UserError
log = logging.getLogger(__name__)
@ -20,8 +22,16 @@ def docker_client(version=None):
if 'DOCKER_CLIENT_TIMEOUT' in os.environ:
log.warn('The DOCKER_CLIENT_TIMEOUT environment variable is deprecated. Please use COMPOSE_HTTP_TIMEOUT instead.')
kwargs = kwargs_from_env(assert_hostname=False)
try:
kwargs = kwargs_from_env(assert_hostname=False)
except TLSParameterError:
raise UserError(
'TLS configuration is invalid - make sure your DOCKER_TLS_VERIFY and DOCKER_CERT_PATH are set correctly.\n'
'You might need to run `eval "$(docker-machine env default)"`')
if version:
kwargs['version'] = version
kwargs['timeout'] = HTTP_TIMEOUT
return Client(**kwargs)