diff --git a/docker/api/image.py b/docker/api/image.py
index a9f801e9..d3fed5c0 100644
--- a/docker/api/image.py
+++ b/docker/api/image.py
@@ -334,7 +334,8 @@ class ImageApiMixin(object):
         Args:
             repository (str): The repository to pull
             tag (str): The tag to pull
-            stream (bool): Stream the output as a generator
+            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``
diff --git a/docker/models/images.py b/docker/models/images.py
index 4578c0bd..30e86f10 100644
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -1,5 +1,6 @@
 import itertools
 import re
+import warnings
 
 import six
 
@@ -425,7 +426,21 @@ class ImageCollection(Collection):
         if not tag:
             repository, tag = parse_repository_tag(repository)
 
-        self.client.api.pull(repository, tag=tag, **kwargs)
+        if 'stream' in kwargs:
+            warnings.warn(
+                '`stream` is not a valid parameter for this method'
+                ' and will be overridden'
+            )
+            del kwargs['stream']
+
+        pull_log = self.client.api.pull(
+            repository, tag=tag, stream=True, **kwargs
+        )
+        for _ in pull_log:
+            # We don't do anything with the logs, but we need
+            # to keep the connection alive and wait for the image
+            # to be pulled.
+            pass
         if tag:
             return self.get('{0}{2}{1}'.format(
                 repository, tag, '@' if tag.startswith('sha256:') else ':'

Can't pull image with stream=True
Hi,

The scenario is as follows:

Mac 10.13.6
docker version v18.06.0-ce
Python 3.6
(python package) docker==3.5.0
private docker registry (docker hub, private repo)
docker login works ✔️
docker pull $image works ✔️
however, pulling via the docker python api fails when using the parameter `stream=True`:
In terminal window I run :
```
python
>>> client = docker.DockerClient(base_url='unix://var/run/docker.sock')
>>> client.login(username='XXXX', password='XXXX', registry='https://index.docker.io/v1/')
>>> client.images.pull('docker.io/vdmtl/portail-datamigration-worker-gcs-lib:latest', stream=True)

Traceback (most recent call last):
  File "/Users/XXXX/apps/open-data-etl/venv/lib/python3.6/site-packages/docker/api/client.py", line 229, in _raise_for_status
    response.raise_for_status()
  File "/Users/XXX/apps/open-data-etl/venv/lib/python3.6/site-packages/requests/models.py", line 937, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.35/images/docker.io/vdmtl/portail-datamigration-worker-gcs-lib:latest/json

>>> client.images.pull('docker.io/vdmtl/portail-datamigration-worker-gcs-lib:latest')
<Image: 'vdmtl/portail-datamigration-worker-gcs-lib:latest'>
```
As you can see removing `stream=True` is necessary in order to download my image.




diff --git a/tests/unit/models_containers_test.py b/tests/unit/models_containers_test.py
index 22dd2410..39e409e4 100644
--- a/tests/unit/models_containers_test.py
+++ b/tests/unit/models_containers_test.py
@@ -232,7 +232,9 @@ class ContainerCollectionTest(unittest.TestCase):
         container = client.containers.run('alpine', 'sleep 300', detach=True)
 
         assert container.id == FAKE_CONTAINER_ID
-        client.api.pull.assert_called_with('alpine', platform=None, tag=None)
+        client.api.pull.assert_called_with(
+            'alpine', platform=None, tag=None, stream=True
+        )
 
     def test_run_with_error(self):
         client = make_fake_client()
diff --git a/tests/unit/models_images_test.py b/tests/unit/models_images_test.py
index 67832795..fd894ab7 100644
--- a/tests/unit/models_images_test.py
+++ b/tests/unit/models_images_test.py
@@ -1,6 +1,8 @@
+import unittest
+import warnings
+
 from docker.constants import DEFAULT_DATA_CHUNK_SIZE
 from docker.models.images import Image
-import unittest
 
 from .fake_api import FAKE_IMAGE_ID
 from .fake_api_client import make_fake_client
@@ -43,7 +45,9 @@ class ImageCollectionTest(unittest.TestCase):
     def test_pull(self):
         client = make_fake_client()
         image = client.images.pull('test_image:latest')
-        client.api.pull.assert_called_with('test_image', tag='latest')
+        client.api.pull.assert_called_with(
+            'test_image', tag='latest', stream=True
+        )
         client.api.inspect_image.assert_called_with('test_image:latest')
         assert isinstance(image, Image)
         assert image.id == FAKE_IMAGE_ID
@@ -51,7 +55,9 @@ class ImageCollectionTest(unittest.TestCase):
     def test_pull_multiple(self):
         client = make_fake_client()
         images = client.images.pull('test_image')
-        client.api.pull.assert_called_with('test_image', tag=None)
+        client.api.pull.assert_called_with(
+            'test_image', tag=None, stream=True
+        )
         client.api.images.assert_called_with(
             all=False, name='test_image', filters=None
         )
@@ -61,6 +67,16 @@ class ImageCollectionTest(unittest.TestCase):
         assert isinstance(image, Image)
         assert image.id == FAKE_IMAGE_ID
 
+    def test_pull_with_stream_param(self):
+        client = make_fake_client()
+        with warnings.catch_warnings(record=True) as w:
+            client.images.pull('test_image', stream=True)
+
+        assert len(w) == 1
+        assert str(w[0].message).startswith(
+            '`stream` is not a valid parameter'
+        )
+
     def test_push(self):
         client = make_fake_client()
         client.images.push('foobar', insecure_registry=True)

pip install -e .[tls,ssh]
parse_log_pytest
requirements.txt
pytest pytest-cov
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
appdirs==1.4.3
asn1crypto==0.22.0
attrs==22.2.0
backports.ssl-match-hostname==3.5.0.1
bcrypt==4.0.1
certifi==2021.5.30
cffi==1.10.0
chardet==3.0.4
coverage==6.2
cryptography==3.2.1
-e git+https://github.com/docker/docker-py.git@e1e4048753aafc96571752cf54d96df7b24156d3#egg=docker
docker-pycreds==0.3.0
enum34==1.1.6
idna==2.5
importlib-metadata==4.8.3
iniconfig==1.1.1
ipaddress==1.0.18
packaging==16.8
paramiko==2.4.2
pluggy==1.0.0
py==1.11.0
pyasn1==0.5.1
pycparser==2.17
PyNaCl==1.5.0
pyOpenSSL==18.0.0
pyparsing==2.2.0
pytest==7.0.1
pytest-cov==4.0.0
requests==2.20.0
six==1.10.0
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.24.3
websocket-client==0.40.0
zipp==3.6.0

name: docker-py
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - appdirs==1.4.3
      - asn1crypto==0.22.0
      - attrs==22.2.0
      - backports-ssl-match-hostname==3.5.0.1
      - bcrypt==4.0.1
      - cffi==1.10.0
      - chardet==3.0.4
      - coverage==6.2
      - cryptography==3.2.1
      - docker-pycreds==0.3.0
      - enum34==1.1.6
      - idna==2.5
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - ipaddress==1.0.18
      - packaging==16.8
      - paramiko==2.4.2
      - pluggy==1.0.0
      - py==1.11.0
      - pyasn1==0.5.1
      - pycparser==2.17
      - pynacl==1.5.0
      - pyopenssl==18.0.0
      - pyparsing==2.2.0
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - requests==2.20.0
      - six==1.10.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.24.3
      - websocket-client==0.40.0
      - zipp==3.6.0
prefix: /opt/conda/envs/docker-py

tests/unit/models_containers_test.py::ContainerCollectionTest::test_run_pull tests/unit/models_images_test.py::ImageCollectionTest::test_pull tests/unit/models_images_test.py::ImageCollectionTest::test_pull_multiple tests/unit/models_images_test.py::ImageCollectionTest::test_pull_with_stream_param
tests/unit/models_containers_test.py::ContainerCollectionTest::test_create tests/unit/models_containers_test.py::ContainerCollectionTest::test_create_container_args tests/unit/models_containers_test.py::ContainerCollectionTest::test_create_with_image_object tests/unit/models_containers_test.py::ContainerCollectionTest::test_get tests/unit/models_containers_test.py::ContainerCollectionTest::test_list tests/unit/models_containers_test.py::ContainerCollectionTest::test_list_ignore_removed tests/unit/models_containers_test.py::ContainerCollectionTest::test_run tests/unit/models_containers_test.py::ContainerCollectionTest::test_run_detach tests/unit/models_containers_test.py::ContainerCollectionTest::test_run_remove tests/unit/models_containers_test.py::ContainerCollectionTest::test_run_with_error tests/unit/models_containers_test.py::ContainerCollectionTest::test_run_with_image_object tests/unit/models_containers_test.py::ContainerTest::test_attach tests/unit/models_containers_test.py::ContainerTest::test_commit tests/unit/models_containers_test.py::ContainerTest::test_diff tests/unit/models_containers_test.py::ContainerTest::test_exec_run tests/unit/models_containers_test.py::ContainerTest::test_exec_run_failure tests/unit/models_containers_test.py::ContainerTest::test_export tests/unit/models_containers_test.py::ContainerTest::test_get_archive tests/unit/models_containers_test.py::ContainerTest::test_image tests/unit/models_containers_test.py::ContainerTest::test_kill tests/unit/models_containers_test.py::ContainerTest::test_labels tests/unit/models_containers_test.py::ContainerTest::test_logs tests/unit/models_containers_test.py::ContainerTest::test_name tests/unit/models_containers_test.py::ContainerTest::test_pause tests/unit/models_containers_test.py::ContainerTest::test_put_archive tests/unit/models_containers_test.py::ContainerTest::test_remove tests/unit/models_containers_test.py::ContainerTest::test_rename tests/unit/models_containers_test.py::ContainerTest::test_resize tests/unit/models_containers_test.py::ContainerTest::test_restart tests/unit/models_containers_test.py::ContainerTest::test_start tests/unit/models_containers_test.py::ContainerTest::test_stats tests/unit/models_containers_test.py::ContainerTest::test_status tests/unit/models_containers_test.py::ContainerTest::test_stop tests/unit/models_containers_test.py::ContainerTest::test_top tests/unit/models_containers_test.py::ContainerTest::test_unpause tests/unit/models_containers_test.py::ContainerTest::test_update tests/unit/models_containers_test.py::ContainerTest::test_wait tests/unit/models_images_test.py::ImageCollectionTest::test_build tests/unit/models_images_test.py::ImageCollectionTest::test_get tests/unit/models_images_test.py::ImageCollectionTest::test_labels tests/unit/models_images_test.py::ImageCollectionTest::test_list tests/unit/models_images_test.py::ImageCollectionTest::test_load tests/unit/models_images_test.py::ImageCollectionTest::test_push tests/unit/models_images_test.py::ImageCollectionTest::test_remove tests/unit/models_images_test.py::ImageCollectionTest::test_search tests/unit/models_images_test.py::ImageTest::test_history tests/unit/models_images_test.py::ImageTest::test_save tests/unit/models_images_test.py::ImageTest::test_short_id tests/unit/models_images_test.py::ImageTest::test_tag tests/unit/models_images_test.py::ImageTest::test_tags
docker/models/images.py docker/api/image.py
docker/models/images.py docker/api/image.py