We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Exception retrieving untagged images on api >= 1.24
Docker API >= 1.24 will return a null object if image tags DNE instead of not including it in the response. This makes the dict.get fail to catch the null case and the list comprehension to iterate over a non-iterable.

```
  File "<stdin>", line 1, in <module>
  File "docker/models/images.py", line 16, in __repr__
    return "<%s: '%s'>" % (self.__class__.__name__, "', '".join(self.tags))
  File "docker/models/images.py", line 34, in tags
    tag for tag in self.attrs.get('RepoTags', [])
TypeError: 'NoneType' object is not iterable
```

This is similar to an issue seen in [salt](https://github.com/saltstack/salt/pull/35447/commits/b833b5f9587534d3b843a026ef91abc4ec929d0f)

Was able to get things working with a pretty quick change:
```
diff --git a/docker/models/images.py b/docker/models/images.py
index 32068e6..39a640d 100644
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -30,9 +30,11 @@ class Image(Model):
         """
         The image's tags.
         """
+        tags = self.attrs.get('RepoTags', [])
+        if tags is None:
+            return []
         return [
-            tag for tag in self.attrs.get('RepoTags', [])
-            if tag != '<none>:<none>'
+            tag for tag in tags if tag != '<none>:<none>'
         ]
 
     def history(self):
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docker/models/images.py`
Content:
```
1 import re
2 
3 import six
4 
5 from ..api import APIClient
6 from ..errors import BuildError
7 from ..utils.json_stream import json_stream
8 from .resource import Collection, Model
9 
10 
11 class Image(Model):
12     """
13     An image on the server.
14     """
15     def __repr__(self):
16         return "<%s: '%s'>" % (self.__class__.__name__, "', '".join(self.tags))
17 
18     @property
19     def short_id(self):
20         """
21         The ID of the image truncated to 10 characters, plus the ``sha256:``
22         prefix.
23         """
24         if self.id.startswith('sha256:'):
25             return self.id[:17]
26         return self.id[:10]
27 
28     @property
29     def tags(self):
30         """
31         The image's tags.
32         """
33         return [
34             tag for tag in self.attrs.get('RepoTags', [])
35             if tag != '<none>:<none>'
36         ]
37 
38     def history(self):
39         """
40         Show the history of an image.
41 
42         Returns:
43             (str): The history of the image.
44 
45         Raises:
46             :py:class:`docker.errors.APIError`
47                 If the server returns an error.
48         """
49         return self.client.api.history(self.id)
50 
51     def save(self):
52         """
53         Get a tarball of an image. Similar to the ``docker save`` command.
54 
55         Returns:
56             (urllib3.response.HTTPResponse object): The response from the
57             daemon.
58 
59         Raises:
60             :py:class:`docker.errors.APIError`
61                 If the server returns an error.
62 
63         Example:
64 
65             >>> image = cli.get("fedora:latest")
66             >>> resp = image.save()
67             >>> f = open('/tmp/fedora-latest.tar', 'w')
68             >>> f.write(resp.data)
69             >>> f.close()
70         """
71         return self.client.api.get_image(self.id)
72 
73     def tag(self, repository, tag=None, **kwargs):
74         """
75         Tag this image into a repository. Similar to the ``docker tag``
76         command.
77 
78         Args:
79             repository (str): The repository to set for the tag
80             tag (str): The tag name
81             force (bool): Force
82 
83         Raises:
84             :py:class:`docker.errors.APIError`
85                 If the server returns an error.
86 
87         Returns:
88             (bool): ``True`` if successful
89         """
90         self.client.api.tag(self.id, repository, tag=tag, **kwargs)
91 
92 
93 class ImageCollection(Collection):
94     model = Image
95 
96     def build(self, **kwargs):
97         """
98         Build an image and return it. Similar to the ``docker build``
99         command. Either ``path`` or ``fileobj`` must be set.
100 
101         If you have a tar file for the Docker build context (including a
102         Dockerfile) already, pass a readable file-like object to ``fileobj``
103         and also pass ``custom_context=True``. If the stream is compressed
104         also, set ``encoding`` to the correct value (e.g ``gzip``).
105 
106         If you want to get the raw output of the build, use the
107         :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
108         low-level API.
109 
110         Args:
111             path (str): Path to the directory containing the Dockerfile
112             fileobj: A file object to use as the Dockerfile. (Or a file-like
113                 object)
114             tag (str): A tag to add to the final image
115             quiet (bool): Whether to return the status
116             nocache (bool): Don't use the cache when set to ``True``
117             rm (bool): Remove intermediate containers. The ``docker build``
118                 command now defaults to ``--rm=true``, but we have kept the old
119                 default of `False` to preserve backward compatibility
120             stream (bool): *Deprecated for API version > 1.8 (always True)*.
121                 Return a blocking generator you can iterate over to retrieve
122                 build output as it happens
123             timeout (int): HTTP timeout
124             custom_context (bool): Optional if using ``fileobj``
125             encoding (str): The encoding for a stream. Set to ``gzip`` for
126                 compressing
127             pull (bool): Downloads any updates to the FROM image in Dockerfiles
128             forcerm (bool): Always remove intermediate containers, even after
129                 unsuccessful builds
130             dockerfile (str): path within the build context to the Dockerfile
131             buildargs (dict): A dictionary of build arguments
132             container_limits (dict): A dictionary of limits applied to each
133                 container created by the build process. Valid keys:
134 
135                 - memory (int): set memory limit for build
136                 - memswap (int): Total memory (memory + swap), -1 to disable
137                     swap
138                 - cpushares (int): CPU shares (relative weight)
139                 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
140                     ``"0-3"``, ``"0,1"``
141             decode (bool): If set to ``True``, the returned stream will be
142                 decoded into dicts on the fly. Default ``False``.
143 
144         Returns:
145             (:py:class:`Image`): The built image.
146 
147         Raises:
148             :py:class:`docker.errors.BuildError`
149                 If there is an error during the build.
150             :py:class:`docker.errors.APIError`
151                 If the server returns any other error.
152             ``TypeError``
153                 If neither ``path`` nor ``fileobj`` is specified.
154         """
155         resp = self.client.api.build(**kwargs)
156         if isinstance(resp, six.string_types):
157             return self.get(resp)
158         events = list(json_stream(resp))
159         if not events:
160             return BuildError('Unknown')
161         event = events[-1]
162         if 'stream' in event:
163             match = re.search(r'Successfully built ([0-9a-f]+)',
164                               event.get('stream', ''))
165             if match:
166                 image_id = match.group(1)
167                 return self.get(image_id)
168 
169         raise BuildError(event.get('error') or event)
170 
171     def get(self, name):
172         """
173         Gets an image.
174 
175         Args:
176             name (str): The name of the image.
177 
178         Returns:
179             (:py:class:`Image`): The image.
180 
181         Raises:
182             :py:class:`docker.errors.ImageNotFound` If the image does not
183             exist.
184             :py:class:`docker.errors.APIError`
185                 If the server returns an error.
186         """
187         return self.prepare_model(self.client.api.inspect_image(name))
188 
189     def list(self, name=None, all=False, filters=None):
190         """
191         List images on the server.
192 
193         Args:
194             name (str): Only show images belonging to the repository ``name``
195             all (bool): Show intermediate image layers. By default, these are
196                 filtered out.
197             filters (dict): Filters to be processed on the image list.
198                 Available filters:
199                 - ``dangling`` (bool)
200                 - ``label`` (str): format either ``key`` or ``key=value``
201 
202         Returns:
203             (list of :py:class:`Image`): The images.
204 
205         Raises:
206             :py:class:`docker.errors.APIError`
207                 If the server returns an error.
208         """
209         resp = self.client.api.images(name=name, all=all, filters=filters)
210         return [self.prepare_model(r) for r in resp]
211 
212     def load(self, data):
213         """
214         Load an image that was previously saved using
215         :py:meth:`~docker.models.images.Image.save` (or ``docker save``).
216         Similar to ``docker load``.
217 
218         Args:
219             data (binary): Image data to be loaded.
220 
221         Raises:
222             :py:class:`docker.errors.APIError`
223                 If the server returns an error.
224         """
225         return self.client.api.load_image(data)
226 
227     def pull(self, name, **kwargs):
228         """
229         Pull an image of the given name and return it. Similar to the
230         ``docker pull`` command.
231 
232         If you want to get the raw pull output, use the
233         :py:meth:`~docker.api.image.ImageApiMixin.pull` method in the
234         low-level API.
235 
236         Args:
237             repository (str): The repository to pull
238             tag (str): The tag to pull
239             insecure_registry (bool): Use an insecure registry
240             auth_config (dict): Override the credentials that
241                 :py:meth:`~docker.client.DockerClient.login` has set for
242                 this request. ``auth_config`` should contain the ``username``
243                 and ``password`` keys to be valid.
244 
245         Returns:
246             (:py:class:`Image`): The image that has been pulled.
247 
248         Raises:
249             :py:class:`docker.errors.APIError`
250                 If the server returns an error.
251 
252         Example:
253 
254             >>> image = client.images.pull('busybox')
255         """
256         self.client.api.pull(name, **kwargs)
257         return self.get(name)
258 
259     def push(self, repository, tag=None, **kwargs):
260         return self.client.api.push(repository, tag=tag, **kwargs)
261     push.__doc__ = APIClient.push.__doc__
262 
263     def remove(self, *args, **kwargs):
264         self.client.api.remove_image(*args, **kwargs)
265     remove.__doc__ = APIClient.remove_image.__doc__
266 
267     def search(self, *args, **kwargs):
268         return self.client.api.search(*args, **kwargs)
269     search.__doc__ = APIClient.search.__doc__
270
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/docker/models/images.py b/docker/models/images.py
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -30,10 +30,10 @@
         """
         The image's tags.
         """
-        return [
-            tag for tag in self.attrs.get('RepoTags', [])
-            if tag != '<none>:<none>'
-        ]
+        tags = self.attrs.get('RepoTags')
+        if tags is None:
+            tags = []
+        return [tag for tag in tags if tag != '<none>:<none>']
 
     def history(self):
         """

{"golden_diff": "diff --git a/docker/models/images.py b/docker/models/images.py\n--- a/docker/models/images.py\n+++ b/docker/models/images.py\n@@ -30,10 +30,10 @@\n         \"\"\"\n         The image's tags.\n         \"\"\"\n-        return [\n-            tag for tag in self.attrs.get('RepoTags', [])\n-            if tag != '<none>:<none>'\n-        ]\n+        tags = self.attrs.get('RepoTags')\n+        if tags is None:\n+            tags = []\n+        return [tag for tag in tags if tag != '<none>:<none>']\n \n     def history(self):\n         \"\"\"\n", "issue": "Exception retrieving untagged images on api >= 1.24\nDocker API >= 1.24 will return a null object if image tags DNE instead of not including it in the response. This makes the dict.get fail to catch the null case and the list comprehension to iterate over a non-iterable.\r\n\r\n```\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"docker/models/images.py\", line 16, in __repr__\r\n    return \"<%s: '%s'>\" % (self.__class__.__name__, \"', '\".join(self.tags))\r\n  File \"docker/models/images.py\", line 34, in tags\r\n    tag for tag in self.attrs.get('RepoTags', [])\r\nTypeError: 'NoneType' object is not iterable\r\n```\r\n\r\nThis is similar to an issue seen in [salt](https://github.com/saltstack/salt/pull/35447/commits/b833b5f9587534d3b843a026ef91abc4ec929d0f)\r\n\r\nWas able to get things working with a pretty quick change:\r\n```\r\ndiff --git a/docker/models/images.py b/docker/models/images.py\r\nindex 32068e6..39a640d 100644\r\n--- a/docker/models/images.py\r\n+++ b/docker/models/images.py\r\n@@ -30,9 +30,11 @@ class Image(Model):\r\n         \"\"\"\r\n         The image's tags.\r\n         \"\"\"\r\n+        tags = self.attrs.get('RepoTags', [])\r\n+        if tags is None:\r\n+            return []\r\n         return [\r\n-            tag for tag in self.attrs.get('RepoTags', [])\r\n-            if tag != '<none>:<none>'\r\n+            tag for tag in tags if tag != '<none>:<none>'\r\n         ]\r\n \r\n     def history(self):\r\n```\n", "before_files": [{"content": "import re\n\nimport six\n\nfrom ..api import APIClient\nfrom ..errors import BuildError\nfrom ..utils.json_stream import json_stream\nfrom .resource import Collection, Model\n\n\nclass Image(Model):\n    \"\"\"\n    An image on the server.\n    \"\"\"\n    def __repr__(self):\n        return \"<%s: '%s'>\" % (self.__class__.__name__, \"', '\".join(self.tags))\n\n    @property\n    def short_id(self):\n        \"\"\"\n        The ID of the image truncated to 10 characters, plus the ``sha256:``\n        prefix.\n        \"\"\"\n        if self.id.startswith('sha256:'):\n            return self.id[:17]\n        return self.id[:10]\n\n    @property\n    def tags(self):\n        \"\"\"\n        The image's tags.\n        \"\"\"\n        return [\n            tag for tag in self.attrs.get('RepoTags', [])\n            if tag != '<none>:<none>'\n        ]\n\n    def history(self):\n        \"\"\"\n        Show the history of an image.\n\n        Returns:\n            (str): The history of the image.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self.client.api.history(self.id)\n\n    def save(self):\n        \"\"\"\n        Get a tarball of an image. Similar to the ``docker save`` command.\n\n        Returns:\n            (urllib3.response.HTTPResponse object): The response from the\n            daemon.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> image = cli.get(\"fedora:latest\")\n            >>> resp = image.save()\n            >>> f = open('/tmp/fedora-latest.tar', 'w')\n            >>> f.write(resp.data)\n            >>> f.close()\n        \"\"\"\n        return self.client.api.get_image(self.id)\n\n    def tag(self, repository, tag=None, **kwargs):\n        \"\"\"\n        Tag this image into a repository. Similar to the ``docker tag``\n        command.\n\n        Args:\n            repository (str): The repository to set for the tag\n            tag (str): The tag name\n            force (bool): Force\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Returns:\n            (bool): ``True`` if successful\n        \"\"\"\n        self.client.api.tag(self.id, repository, tag=tag, **kwargs)\n\n\nclass ImageCollection(Collection):\n    model = Image\n\n    def build(self, **kwargs):\n        \"\"\"\n        Build an image and return it. Similar to the ``docker build``\n        command. Either ``path`` or ``fileobj`` must be set.\n\n        If you have a tar file for the Docker build context (including a\n        Dockerfile) already, pass a readable file-like object to ``fileobj``\n        and also pass ``custom_context=True``. If the stream is compressed\n        also, set ``encoding`` to the correct value (e.g ``gzip``).\n\n        If you want to get the raw output of the build, use the\n        :py:meth:`~docker.api.build.BuildApiMixin.build` method in the\n        low-level API.\n\n        Args:\n            path (str): Path to the directory containing the Dockerfile\n            fileobj: A file object to use as the Dockerfile. (Or a file-like\n                object)\n            tag (str): A tag to add to the final image\n            quiet (bool): Whether to return the status\n            nocache (bool): Don't use the cache when set to ``True``\n            rm (bool): Remove intermediate containers. The ``docker build``\n                command now defaults to ``--rm=true``, but we have kept the old\n                default of `False` to preserve backward compatibility\n            stream (bool): *Deprecated for API version > 1.8 (always True)*.\n                Return a blocking generator you can iterate over to retrieve\n                build output as it happens\n            timeout (int): HTTP timeout\n            custom_context (bool): Optional if using ``fileobj``\n            encoding (str): The encoding for a stream. Set to ``gzip`` for\n                compressing\n            pull (bool): Downloads any updates to the FROM image in Dockerfiles\n            forcerm (bool): Always remove intermediate containers, even after\n                unsuccessful builds\n            dockerfile (str): path within the build context to the Dockerfile\n            buildargs (dict): A dictionary of build arguments\n            container_limits (dict): A dictionary of limits applied to each\n                container created by the build process. Valid keys:\n\n                - memory (int): set memory limit for build\n                - memswap (int): Total memory (memory + swap), -1 to disable\n                    swap\n                - cpushares (int): CPU shares (relative weight)\n                - cpusetcpus (str): CPUs in which to allow execution, e.g.,\n                    ``\"0-3\"``, ``\"0,1\"``\n            decode (bool): If set to ``True``, the returned stream will be\n                decoded into dicts on the fly. Default ``False``.\n\n        Returns:\n            (:py:class:`Image`): The built image.\n\n        Raises:\n            :py:class:`docker.errors.BuildError`\n                If there is an error during the build.\n            :py:class:`docker.errors.APIError`\n                If the server returns any other error.\n            ``TypeError``\n                If neither ``path`` nor ``fileobj`` is specified.\n        \"\"\"\n        resp = self.client.api.build(**kwargs)\n        if isinstance(resp, six.string_types):\n            return self.get(resp)\n        events = list(json_stream(resp))\n        if not events:\n            return BuildError('Unknown')\n        event = events[-1]\n        if 'stream' in event:\n            match = re.search(r'Successfully built ([0-9a-f]+)',\n                              event.get('stream', ''))\n            if match:\n                image_id = match.group(1)\n                return self.get(image_id)\n\n        raise BuildError(event.get('error') or event)\n\n    def get(self, name):\n        \"\"\"\n        Gets an image.\n\n        Args:\n            name (str): The name of the image.\n\n        Returns:\n            (:py:class:`Image`): The image.\n\n        Raises:\n            :py:class:`docker.errors.ImageNotFound` If the image does not\n            exist.\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self.prepare_model(self.client.api.inspect_image(name))\n\n    def list(self, name=None, all=False, filters=None):\n        \"\"\"\n        List images on the server.\n\n        Args:\n            name (str): Only show images belonging to the repository ``name``\n            all (bool): Show intermediate image layers. By default, these are\n                filtered out.\n            filters (dict): Filters to be processed on the image list.\n                Available filters:\n                - ``dangling`` (bool)\n                - ``label`` (str): format either ``key`` or ``key=value``\n\n        Returns:\n            (list of :py:class:`Image`): The images.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        resp = self.client.api.images(name=name, all=all, filters=filters)\n        return [self.prepare_model(r) for r in resp]\n\n    def load(self, data):\n        \"\"\"\n        Load an image that was previously saved using\n        :py:meth:`~docker.models.images.Image.save` (or ``docker save``).\n        Similar to ``docker load``.\n\n        Args:\n            data (binary): Image data to be loaded.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self.client.api.load_image(data)\n\n    def pull(self, name, **kwargs):\n        \"\"\"\n        Pull an image of the given name and return it. Similar to the\n        ``docker pull`` command.\n\n        If you want to get the raw pull output, use the\n        :py:meth:`~docker.api.image.ImageApiMixin.pull` method in the\n        low-level API.\n\n        Args:\n            repository (str): The repository to pull\n            tag (str): The tag to pull\n            insecure_registry (bool): Use an insecure registry\n            auth_config (dict): Override the credentials that\n                :py:meth:`~docker.client.DockerClient.login` has set for\n                this request. ``auth_config`` should contain the ``username``\n                and ``password`` keys to be valid.\n\n        Returns:\n            (:py:class:`Image`): The image that has been pulled.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> image = client.images.pull('busybox')\n        \"\"\"\n        self.client.api.pull(name, **kwargs)\n        return self.get(name)\n\n    def push(self, repository, tag=None, **kwargs):\n        return self.client.api.push(repository, tag=tag, **kwargs)\n    push.__doc__ = APIClient.push.__doc__\n\n    def remove(self, *args, **kwargs):\n        self.client.api.remove_image(*args, **kwargs)\n    remove.__doc__ = APIClient.remove_image.__doc__\n\n    def search(self, *args, **kwargs):\n        return self.client.api.search(*args, **kwargs)\n    search.__doc__ = APIClient.search.__doc__\n", "path": "docker/models/images.py"}], "after_files": [{"content": "import re\n\nimport six\n\nfrom ..api import APIClient\nfrom ..errors import BuildError\nfrom ..utils.json_stream import json_stream\nfrom .resource import Collection, Model\n\n\nclass Image(Model):\n    \"\"\"\n    An image on the server.\n    \"\"\"\n    def __repr__(self):\n        return \"<%s: '%s'>\" % (self.__class__.__name__, \"', '\".join(self.tags))\n\n    @property\n    def short_id(self):\n        \"\"\"\n        The ID of the image truncated to 10 characters, plus the ``sha256:``\n        prefix.\n        \"\"\"\n        if self.id.startswith('sha256:'):\n            return self.id[:17]\n        return self.id[:10]\n\n    @property\n    def tags(self):\n        \"\"\"\n        The image's tags.\n        \"\"\"\n        tags = self.attrs.get('RepoTags')\n        if tags is None:\n            tags = []\n        return [tag for tag in tags if tag != '<none>:<none>']\n\n    def history(self):\n        \"\"\"\n        Show the history of an image.\n\n        Returns:\n            (str): The history of the image.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self.client.api.history(self.id)\n\n    def save(self):\n        \"\"\"\n        Get a tarball of an image. Similar to the ``docker save`` command.\n\n        Returns:\n            (urllib3.response.HTTPResponse object): The response from the\n            daemon.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> image = cli.get(\"fedora:latest\")\n            >>> resp = image.save()\n            >>> f = open('/tmp/fedora-latest.tar', 'w')\n            >>> f.write(resp.data)\n            >>> f.close()\n        \"\"\"\n        return self.client.api.get_image(self.id)\n\n    def tag(self, repository, tag=None, **kwargs):\n        \"\"\"\n        Tag this image into a repository. Similar to the ``docker tag``\n        command.\n\n        Args:\n            repository (str): The repository to set for the tag\n            tag (str): The tag name\n            force (bool): Force\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Returns:\n            (bool): ``True`` if successful\n        \"\"\"\n        self.client.api.tag(self.id, repository, tag=tag, **kwargs)\n\n\nclass ImageCollection(Collection):\n    model = Image\n\n    def build(self, **kwargs):\n        \"\"\"\n        Build an image and return it. Similar to the ``docker build``\n        command. Either ``path`` or ``fileobj`` must be set.\n\n        If you have a tar file for the Docker build context (including a\n        Dockerfile) already, pass a readable file-like object to ``fileobj``\n        and also pass ``custom_context=True``. If the stream is compressed\n        also, set ``encoding`` to the correct value (e.g ``gzip``).\n\n        If you want to get the raw output of the build, use the\n        :py:meth:`~docker.api.build.BuildApiMixin.build` method in the\n        low-level API.\n\n        Args:\n            path (str): Path to the directory containing the Dockerfile\n            fileobj: A file object to use as the Dockerfile. (Or a file-like\n                object)\n            tag (str): A tag to add to the final image\n            quiet (bool): Whether to return the status\n            nocache (bool): Don't use the cache when set to ``True``\n            rm (bool): Remove intermediate containers. The ``docker build``\n                command now defaults to ``--rm=true``, but we have kept the old\n                default of `False` to preserve backward compatibility\n            stream (bool): *Deprecated for API version > 1.8 (always True)*.\n                Return a blocking generator you can iterate over to retrieve\n                build output as it happens\n            timeout (int): HTTP timeout\n            custom_context (bool): Optional if using ``fileobj``\n            encoding (str): The encoding for a stream. Set to ``gzip`` for\n                compressing\n            pull (bool): Downloads any updates to the FROM image in Dockerfiles\n            forcerm (bool): Always remove intermediate containers, even after\n                unsuccessful builds\n            dockerfile (str): path within the build context to the Dockerfile\n            buildargs (dict): A dictionary of build arguments\n            container_limits (dict): A dictionary of limits applied to each\n                container created by the build process. Valid keys:\n\n                - memory (int): set memory limit for build\n                - memswap (int): Total memory (memory + swap), -1 to disable\n                    swap\n                - cpushares (int): CPU shares (relative weight)\n                - cpusetcpus (str): CPUs in which to allow execution, e.g.,\n                    ``\"0-3\"``, ``\"0,1\"``\n            decode (bool): If set to ``True``, the returned stream will be\n                decoded into dicts on the fly. Default ``False``.\n\n        Returns:\n            (:py:class:`Image`): The built image.\n\n        Raises:\n            :py:class:`docker.errors.BuildError`\n                If there is an error during the build.\n            :py:class:`docker.errors.APIError`\n                If the server returns any other error.\n            ``TypeError``\n                If neither ``path`` nor ``fileobj`` is specified.\n        \"\"\"\n        resp = self.client.api.build(**kwargs)\n        if isinstance(resp, six.string_types):\n            return self.get(resp)\n        events = list(json_stream(resp))\n        if not events:\n            return BuildError('Unknown')\n        event = events[-1]\n        if 'stream' in event:\n            match = re.search(r'Successfully built ([0-9a-f]+)',\n                              event.get('stream', ''))\n            if match:\n                image_id = match.group(1)\n                return self.get(image_id)\n\n        raise BuildError(event.get('error') or event)\n\n    def get(self, name):\n        \"\"\"\n        Gets an image.\n\n        Args:\n            name (str): The name of the image.\n\n        Returns:\n            (:py:class:`Image`): The image.\n\n        Raises:\n            :py:class:`docker.errors.ImageNotFound` If the image does not\n            exist.\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self.prepare_model(self.client.api.inspect_image(name))\n\n    def list(self, name=None, all=False, filters=None):\n        \"\"\"\n        List images on the server.\n\n        Args:\n            name (str): Only show images belonging to the repository ``name``\n            all (bool): Show intermediate image layers. By default, these are\n                filtered out.\n            filters (dict): Filters to be processed on the image list.\n                Available filters:\n                - ``dangling`` (bool)\n                - ``label`` (str): format either ``key`` or ``key=value``\n\n        Returns:\n            (list of :py:class:`Image`): The images.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        resp = self.client.api.images(name=name, all=all, filters=filters)\n        return [self.prepare_model(r) for r in resp]\n\n    def load(self, data):\n        \"\"\"\n        Load an image that was previously saved using\n        :py:meth:`~docker.models.images.Image.save` (or ``docker save``).\n        Similar to ``docker load``.\n\n        Args:\n            data (binary): Image data to be loaded.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self.client.api.load_image(data)\n\n    def pull(self, name, **kwargs):\n        \"\"\"\n        Pull an image of the given name and return it. Similar to the\n        ``docker pull`` command.\n\n        If you want to get the raw pull output, use the\n        :py:meth:`~docker.api.image.ImageApiMixin.pull` method in the\n        low-level API.\n\n        Args:\n            repository (str): The repository to pull\n            tag (str): The tag to pull\n            insecure_registry (bool): Use an insecure registry\n            auth_config (dict): Override the credentials that\n                :py:meth:`~docker.client.DockerClient.login` has set for\n                this request. ``auth_config`` should contain the ``username``\n                and ``password`` keys to be valid.\n\n        Returns:\n            (:py:class:`Image`): The image that has been pulled.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> image = client.images.pull('busybox')\n        \"\"\"\n        self.client.api.pull(name, **kwargs)\n        return self.get(name)\n\n    def push(self, repository, tag=None, **kwargs):\n        return self.client.api.push(repository, tag=tag, **kwargs)\n    push.__doc__ = APIClient.push.__doc__\n\n    def remove(self, *args, **kwargs):\n        self.client.api.remove_image(*args, **kwargs)\n    remove.__doc__ = APIClient.remove_image.__doc__\n\n    def search(self, *args, **kwargs):\n        return self.client.api.search(*args, **kwargs)\n    search.__doc__ = APIClient.search.__doc__\n", "path": "docker/models/images.py"}]}