Repository: docker/docker-py
Issue: While authenticated, can pull private dockerhub image, but can't get_registry_data() of that same private image

```python3
dc = docker.from_env()
dc.login('username', 'password')
private_image = dc.images.pull('org/private:staging') # Is successful
private_image_registry_info = dc.images.get_registry_data('org/private:staging') #fails
```

```
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.35/distribution/prg/private:staging/json

During handling of the above exception, another exception occurred:

docker.errors.APIError: 500 Server Error: Internal Server Error ("errors:
denied: requested access to the resource is denied
unauthorized: authentication required
")
```

get_registry_data() for public images works fine.

If I remove the login I get `pull access denied for org/private` which is the expected behavior.

Full stacktrace:

```<Image: 'org/private:staging'>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/docker/api/client.py", line 246, in _raise_for_status
    response.raise_for_status()
  File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.35/distribution/org/private:staging/json

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../docker_cicd", line 103, in <module>
    docker_cicd()
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "../docker_cicd", line 60, in docker_cicd
    output_remote = dc.images.get_registry_data('org/private:staging')
  File "/usr/local/lib/python3.6/dist-packages/docker/models/images.py", line 329, in get_registry_data
    attrs=self.client.api.inspect_distribution(name),
  File "/usr/local/lib/python3.6/dist-packages/docker/utils/decorators.py", line 34, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/docker/api/image.py", line 266, in inspect_distribution
    self._get(self._url("/distribution/{0}/json", image)), True
  File "/usr/local/lib/python3.6/dist-packages/docker/api/client.py", line 252, in _result
    self._raise_for_status(response)
  File "/usr/local/lib/python3.6/dist-packages/docker/api/client.py", line 248, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/usr/local/lib/python3.6/dist-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("errors:
denied: requested access to the resource is denied
unauthorized: authentication required
")
```

Changed files:
docker/api/image.py, docker/models/images.py

diff --git a/docker/api/image.py b/docker/api/image.py
index d3fed5c0..b370b7d8 100644
--- a/docker/api/image.py
+++ b/docker/api/image.py
@@ -247,12 +247,15 @@ class ImageApiMixin(object):
 
     @utils.minimum_version('1.30')
     @utils.check_resource('image')
-    def inspect_distribution(self, image):
+    def inspect_distribution(self, image, auth_config=None):
         """
         Get image digest and platform information by contacting the registry.
 
         Args:
             image (str): The image name to inspect
+            auth_config (dict): Override the credentials that are found in the
+                config for this request.  ``auth_config`` should contain the
+                ``username`` and ``password`` keys to be valid.
 
         Returns:
             (dict): A dict containing distribution data
@@ -261,9 +264,21 @@ class ImageApiMixin(object):
             :py:class:`docker.errors.APIError`
                 If the server returns an error.
         """
+        registry, _ = auth.resolve_repository_name(image)
+
+        headers = {}
+        if auth_config is None:
+            header = auth.get_config_header(self, registry)
+            if header:
+                headers['X-Registry-Auth'] = header
+        else:
+            log.debug('Sending supplied auth config')
+            headers['X-Registry-Auth'] = auth.encode_header(auth_config)
+
+        url = self._url("/distribution/{0}/json", image)
 
         return self._result(
-            self._get(self._url("/distribution/{0}/json", image)), True
+            self._get(url, headers=headers), True
         )
 
     def load_image(self, data, quiet=None):
@@ -336,10 +351,9 @@ class ImageApiMixin(object):
             tag (str): The tag to pull
             stream (bool): Stream the output as a generator. Make sure to
                 consume the generator, otherwise pull might get cancelled.
-            auth_config (dict): Override the credentials that
-                :py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
-                this request. ``auth_config`` should contain the ``username``
-                and ``password`` keys to be valid.
+            auth_config (dict): Override the credentials that are found in the
+                config for this request.  ``auth_config`` should contain the
+                ``username`` and ``password`` keys to be valid.
             decode (bool): Decode the JSON data from the server into dicts.
                 Only applies with ``stream=True``
             platform (str): Platform in the format ``os[/arch[/variant]]``
@@ -414,10 +428,9 @@ class ImageApiMixin(object):
             repository (str): The repository to push to
             tag (str): An optional tag to push
             stream (bool): Stream the output as a blocking generator
-            auth_config (dict): Override the credentials that
-                :py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
-                this request. ``auth_config`` should contain the ``username``
-                and ``password`` keys to be valid.
+            auth_config (dict): Override the credentials that are found in the
+                config for this request.  ``auth_config`` should contain the
+                ``username`` and ``password`` keys to be valid.
             decode (bool): Decode the JSON data from the server into dicts.
                 Only applies with ``stream=True``
 
diff --git a/docker/models/images.py b/docker/models/images.py
index af94520d..54196829 100644
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -315,22 +315,26 @@ class ImageCollection(Collection):
         """
         return self.prepare_model(self.client.api.inspect_image(name))
 
-    def get_registry_data(self, name):
+    def get_registry_data(self, name, auth_config=None):
         """
         Gets the registry data for an image.
 
         Args:
             name (str): The name of the image.
+            auth_config (dict): Override the credentials that are found in the
+                config for this request.  ``auth_config`` should contain the
+                ``username`` and ``password`` keys to be valid.
 
         Returns:
             (:py:class:`RegistryData`): The data object.
+
         Raises:
             :py:class:`docker.errors.APIError`
                 If the server returns an error.
         """
         return RegistryData(
             image_name=name,
-            attrs=self.client.api.inspect_distribution(name),
+            attrs=self.client.api.inspect_distribution(name, auth_config),
             client=self.client,
             collection=self,
         )
@@ -404,10 +408,9 @@ class ImageCollection(Collection):
         Args:
             repository (str): The repository to pull
             tag (str): The tag to pull
-            auth_config (dict): Override the credentials that
-                :py:meth:`~docker.client.DockerClient.login` has set for
-                this request. ``auth_config`` should contain the ``username``
-                and ``password`` keys to be valid.
+            auth_config (dict): Override the credentials that are found in the
+                config for this request.  ``auth_config`` should contain the
+                ``username`` and ``password`` keys to be valid.
             platform (str): Platform in the format ``os[/arch[/variant]]``
 
         Returns: