Require image info in a fixed format
MODIFY
repo2docker/app.py
repo2docker/app.py
@@ -670,8 +670,7 @@ class Repo2Docker(Application):
# check if we already have an image for this content
client = self.get_engine()
for image in client.images():
- if image["RepoTags"] is not None:
- for tag in image["RepoTags"]:
+ for tag in image.tags:
if tag == self.output_image_spec + ":latest":
return True
return False

MODIFY
repo2docker/docker.py
repo2docker/docker.py
@@ -3,7 +3,7 @@ Docker container engine for repo2docker
"""
import docker
-from .engine import Container, ContainerEngine, ContainerEngineException
+from .engine import Container, ContainerEngine, ContainerEngineException, Image
class DockerContainer(Container):
@@ -78,7 +78,8 @@ class DockerEngine(ContainerEngine):
)
def images(self):
- return self._apiclient.images()
+ images = self._apiclient.images()
+ return [Image(tags=image["RepoTags"]) for image in images]
def inspect_image(self, image):
return self._apiclient.inspect_image(image)

MODIFY
repo2docker/engine.py
repo2docker/engine.py
@@ -84,9 +84,31 @@ class Container(ABC):
"""
+class Image:
+ """
+ Information about a container image
+ """
+
+ def __init__(self, *, tags):
+ self._tags = tags or []
+
+ @property
+ def tags(self):
+ """
+ A list of tags associated with an image.
+
+ If locally built images have a localhost prefix this prefix should be removed or the image may not be recognised.
+ If there are no tags [] will be returned.
+ """
+ return self._tags
+
+ def __repr__(self):
+ return "Image(tags={})".format(self.tags)
+
+
class ContainerEngine(ABC):
"""
- Abstract container engine
+ Abstract container engine.
"""
# containers = Container
@@ -156,7 +178,7 @@ class ContainerEngine(ABC):
Returns
-------
- list[str] : List of images
+ list[Image] : List of Image objects.
"""
@abstractmethod

Require image info in a fixed format