def list_images(self): """ List all available docker images. Image objects returned from this methods will contain a limited amount of metadata in property `short_metadata`. These are just a subset of `.get_metadata()`, but don't require an API call against dockerd. :return: collection of instances of :class:`conu.DockerImage` """ response = [] for im in self.d.images(): try: i_name, tag = parse_reference(im["RepoTags"][0]) except (IndexError, TypeError): i_name, tag = None, None d_im = DockerImage(i_name, tag=tag, identifier=im["Id"], pull_policy=DockerImagePullPolicy.NEVER, short_metadata=im) response.append(d_im) return response
def list_containers(self): """ List all available docker containers. Container objects returned from this methods will contain a limited amount of metadata in property `short_metadata`. These are just a subset of `.inspect()`, but don't require an API call against dockerd. :return: collection of instances of :class:`conu.DockerContainer` """ result = [] for c in self.d.containers(all=True): name = None names = c.get("Names", None) if names: name = names[0] i = DockerImage(None, identifier=c["ImageID"]) cont = DockerContainer(i, c["Id"], name=name) # TODO: docker_client.containers produces different metadata than inspect inspect_to_container_metadata(cont.metadata, c, i) result.append(cont) return result
def setup_class(cls): cls.image = DockerImage(FEDORA_MINIMAL_REPOSITORY, tag=FEDORA_MINIMAL_REPOSITORY_TAG)
def setup_class(cls): cls.image = DockerImage(FEDORA_MINIMAL_REPOSITORY, tag=FEDORA_MINIMAL_REPOSITORY_TAG) cls.container = cls.image.run_via_binary( DockerRunBuilder(command=["sleep", "infinity"])) cls.containers_to_remove.append(cls.container.get_id())