def _get_client(timeout=None):
    kwargs = {}
    get = __salt__['config.get']
    for key, val in (('base_url', 'docker.url'),
                     ('version', 'docker.version')):
        param = get(val, NOTSET)
        if param is not NOTSET:
            kwargs[key] = param
    if timeout is not None:
        # make sure we override default timeout of docker-py
        # only if defined by user.
        kwargs['timeout'] = timeout

    if 'version' not in kwargs:
        # Let docker-py auto detect docker version incase
        # it's not defined by user.
        kwargs['version'] = 'auto'

    if 'base_url' not in kwargs and 'DOCKER_HOST' in os.environ:
        # Check if the DOCKER_HOST environment variable has been set
        kwargs['base_url'] = os.environ.get('DOCKER_HOST')

    client = docker.Client(**kwargs)

    # try to authenticate the client using credentials
    # found in pillars
    registry_auth_config = __pillar__.get('docker-registries', {})
    for key, data in six.iteritems(__pillar__):
        if key.endswith('-docker-registries'):
            registry_auth_config.update(data)

    for registry, creds in six.iteritems(registry_auth_config):
        client.login(creds['username'], password=creds['password'],
                     email=creds.get('email'), registry=registry)

    return client
Get a connection to a docker API (socket or URL)
dataset/ETHPy150Open saltstack/salt/salt/modules/dockerio.py/_get_client