Get a connection to a docker API (socket or URL)

    By default it will use the base docker-py defaults which
    at the time of writing are using the local socket and
    the 1.4 API

    Set those keys in your configuration tree somehow:

        - docker.url: URL to the docker service
        - docker.version: API version to use

    Return: docker client

def _get_client(config, url=None, version=None, timeout=None):
    '''
    Get a connection to a docker API (socket or URL)

    By default it will use the base docker-py defaults which
    at the time of writing are using the local socket and
    the 1.4 API

    Set those keys in your configuration tree somehow:

        - docker.url: URL to the docker service
        - docker.version: API version to use

    Return: docker client
    '''
    if config.get("docker_sock"):
        url=config["docker_sock"]
    client = docker.Client(base_url=url)
    # force 1..5 API for registry login
    if not version:
        if client._version == '1.4':
            client._version = '1.5'
    if getattr(client, '_cfg', None) is None:
        client._cfg = {
            'Configs': {},
            'rootPath': '/dev/null'
        }
    client._cfg.update(_get_config())
    return client