@@ -394,6 +394,7 @@ class Client:
394
394
DEFAULT_DOCKER_HOST = 'unix://var/run/docker.sock'
395
395
DEFAULT_TLS = False
396
396
DEFAULT_TLS_VERIFY = False
397
+ DEFAULT_TLS_HOSTNAME = "localhost"
397
398
DEFAULT_IP = '127.0.0.1'
398
399
DEFAULT_SSH_PORT = '22'
399
400
@@ -409,6 +410,7 @@ class Client:
409
410
ssl_version = 'DOCKER_SSL_VERSION' ,
410
411
tls = 'DOCKER_TLS' ,
411
412
tls_verify = 'DOCKER_TLS_VERIFY' ,
413
+ tls_hostname = 'DOCKER_TLS_HOSTNAME' ,
412
414
timeout = 'DOCKER_TIMEOUT' ,
413
415
private_ssh_port = 'DOCKER_DEFAULT_SSH_PORT' ,
414
416
default_ip = 'DOCKER_DEFAULT_IP' ,
@@ -692,7 +694,7 @@ def get_hosts(self, config):
692
694
api_version = host .get ('version' ) or def_version or self ._args .api_version or \
693
695
self ._env_args .api_version or DEFAULT_DOCKER_API_VERSION
694
696
tls_hostname = host .get ('tls_hostname' ) or def_tls_hostname or self ._args .tls_hostname or \
695
- self ._env_args .tls_hostname
697
+ self ._env_args .tls_hostname or DEFAULT_TLS_HOSTNAME
696
698
tls_verify = host .get ('tls_verify' ) or def_tls_verify or self ._args .tls_verify or \
697
699
self ._env_args .tls_verify or DEFAULT_TLS_VERIFY
698
700
tls = host .get ('tls' ) or def_tls or self ._args .tls or self ._env_args .tls or DEFAULT_TLS
@@ -716,8 +718,8 @@ def get_hosts(self, config):
716
718
717
719
timeout = host .get ('timeout' ) or def_timeout or self ._args .timeout or self ._env_args .timeout or \
718
720
DEFAULT_TIMEOUT_SECONDS
719
- default_ip = host .get ('default_ip' ) or def_ip or self ._args . default_ip_address or \
720
- DEFAULT_IP
721
+ default_ip = host .get ('default_ip' ) or def_ip or self ._env_args . default_ip or \
722
+ self . _args . default_ip_address or DEFAULT_IP
721
723
default_ssh_port = host .get ('private_ssh_port' ) or def_ssh_port or self ._args .private_ssh_port or \
722
724
DEFAULT_SSH_PORT
723
725
host_dict = dict (
@@ -740,7 +742,8 @@ def get_hosts(self, config):
740
742
docker_host = def_host or self ._args .docker_host or self ._env_args .docker_host or DEFAULT_DOCKER_HOST
741
743
api_version = def_version or self ._args .api_version or self ._env_args .api_version or \
742
744
DEFAULT_DOCKER_API_VERSION
743
- tls_hostname = def_tls_hostname or self ._args .tls_hostname or self ._env_args .tls_hostname
745
+ tls_hostname = def_tls_hostname or self ._args .tls_hostname or self ._env_args .tls_hostname or \
746
+ DEFAULT_TLS_HOSTNAME
744
747
tls_verify = def_tls_verify or self ._args .tls_verify or self ._env_args .tls_verify or DEFAULT_TLS_VERIFY
745
748
tls = def_tls or self ._args .tls or self ._env_args .tls or DEFAULT_TLS
746
749
ssl_version = def_ssl_version or self ._args .ssl_version or self ._env_args .ssl_version
@@ -758,7 +761,7 @@ def get_hosts(self, config):
758
761
key_path = os .path .join (key_path , 'key.pem' )
759
762
760
763
timeout = def_timeout or self ._args .timeout or self ._env_args .timeout or DEFAULT_TIMEOUT_SECONDS
761
- default_ip = def_ip or self ._args .default_ip_address or DEFAULT_IP
764
+ default_ip = def_ip or self ._env_args . default_ip or self . _args .default_ip_address or DEFAULT_IP
762
765
default_ssh_port = def_ssh_port or self ._args .private_ssh_port or DEFAULT_SSH_PORT
763
766
host_dict = dict (
764
767
docker_host = docker_host ,
@@ -846,8 +849,8 @@ def _parse_cli_args(self):
846
849
parser .add_argument ('--docker-host' , action = 'store' , default = None ,
847
850
help = "The base url or Unix sock path to connect to the docker daemon. Defaults to %s"
848
851
% (DEFAULT_DOCKER_HOST ))
849
- parser .add_argument ('--tls-hostname' , action = 'store' , default = 'localhost' ,
850
- help = "Host name to expect in TLS certs. Defaults to 'localhost'" )
852
+ parser .add_argument ('--tls-hostname' , action = 'store' , default = None ,
853
+ help = "Host name to expect in TLS certs. Defaults to %s" % DEFAULT_TLS_HOSTNAME )
851
854
parser .add_argument ('--api-version' , action = 'store' , default = None ,
852
855
help = "Docker daemon API version. Defaults to %s" % (DEFAULT_DOCKER_API_VERSION ))
853
856
parser .add_argument ('--timeout' , action = 'store' , default = None ,
0 commit comments