diff options
author | Jun Guo <blackhumour.gj@gmail.com> | 2017-01-04 15:31:12 +0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2017-01-09 16:44:32 -0800 |
commit | cbb730172ff94ea584c6d85b73c96aef35bd058a (patch) | |
tree | b29d3e17673cc632f5d3b23c34b12008671ae5e8 | |
parent | 91851cd5ae8890ec3430f624041384a483d7cd40 (diff) |
Fix 404 issue, change APIError to more accureate ImageNotFound
Signed-off-by: Jun Guo <blackhumour.gj@gmail.com>
-rw-r--r-- | compose/service.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/compose/service.py b/compose/service.py index 1338f154..20a40c68 100644 --- a/compose/service.py +++ b/compose/service.py @@ -10,6 +10,7 @@ from operator import attrgetter import enum import six from docker.errors import APIError +from docker.errors import ImageNotFound from docker.errors import NotFound from docker.types import LogConfig from docker.utils.ports import build_port_bindings @@ -323,11 +324,8 @@ class Service(object): def image(self): try: return self.client.inspect_image(self.image_name) - except APIError as e: - if e.response.status_code == 404 and e.explanation and 'No such image' in str(e.explanation): - raise NoSuchImageError("Image '{}' not found".format(self.image_name)) - else: - raise + except ImageNotFound: + raise NoSuchImageError("Image '{}' not found".format(self.image_name)) @property def image_name(self): |