MCPcopy Index your code
hub / github.com/agent0ai/agent-zero / get_image_containers

Method get_image_containers

helpers/docker.py:47–63  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

45 if self.logger: self.logger.log(type="error", content=f"Failed to stop and remove the container: {e}")
46
47 def get_image_containers(self):
48 if not self.client: self.client = self.init_docker()
49 containers = self.client.containers.list(all=True, filters={"ancestor": self.image})
50 infos = []
51 for container in containers:
52 infos.append({
53 "id": container.id,
54 "name": container.name,
55 "status": container.status,
56 "image": container.image,
57 "ports": container.ports,
58 "web_port": (container.ports.get("80/tcp") or [{}])[0].get("HostPort"),
59 "ssh_port": (container.ports.get("22/tcp") or [{}])[0].get("HostPort"),
60 # "volumes": container.volumes,
61 # "data_folder": container.volumes["/a0"],
62 })
63 return infos
64
65 def start_container(self) -> None:
66 if not self.client: self.client = self.init_docker()

Callers

nothing calls this directly

Calls 3

init_dockerMethod · 0.95
listMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected