diff --git a/docker/models/images.py b/docker/models/images.py index 32068e69..6f8f4fe2 100644 --- a/docker/models/images.py +++ b/docker/models/images.py @@ -30,10 +30,10 @@ class Image(Model): """ The image's tags. """ - return [ - tag for tag in self.attrs.get('RepoTags', []) - if tag != ':' - ] + tags = self.attrs.get('RepoTags') + if tags is None: + tags = [] + return [tag for tag in tags if tag != ':'] def history(self): """ diff --git a/tests/unit/models_images_test.py b/tests/unit/models_images_test.py index 392c58d7..efb21166 100644 --- a/tests/unit/models_images_test.py +++ b/tests/unit/models_images_test.py @@ -83,6 +83,11 @@ class ImageTest(unittest.TestCase): }) assert image.tags == [] + image = Image(attrs={ + 'RepoTags': None + }) + assert image.tags == [] + def test_history(self): client = make_fake_client() image = client.images.get(FAKE_IMAGE_ID)