Catch TLSParameterErrors from docker-py

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2016-01-18 19:22:04 +00:00
parent b863fe5723
commit 9ccef1ea91
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)