def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Sets the default of the docker configuration options from the
# current environment. These will possibly be overridded by
# the appropriate entries in the configuration file when parse_file
# is invoked
env = os.environ
self.docker_host = env.get("DOCKER_HOST", "")
if self.docker_host == "":
self.docker_host = "unix://var/run/docker.sock"
# Note that definedness, not value, is considered, meaning
# that defining DOCKER_TLS_VERIFY=0 will still evaluate to True.
# This is consistent with both docker behavior and general shell
# practice.
self.tls_verify = (env.get("DOCKER_TLS_VERIFY", "") != "")
# We don't have an envvar way of saying TLS = True, so we rely on
# TLS_VERIFY set status
self.tls = self.tls_verify
cert_path = env.get("DOCKER_CERT_PATH",
os.path.join(os.path.expanduser("~"), ".docker"))
self.tls_cert = os.path.join(cert_path, 'cert.pem')
self.tls_key = os.path.join(cert_path, 'key.pem')
self.tls_ca = os.path.join(cert_path, 'ca.pem')
if self.tls:
self.docker_host = self.docker_host.replace('tcp://', 'https://')
# -------------------------------------------------------------------------
# Public
评论列表
文章目录