MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / __init__

Method __init__

camel/runtime/docker_runtime.py:53–78  ·  view source on GitHub ↗
(
        self, image: str, port: int = 8000, remove: bool = True, **kwargs
    )

Source from the content-addressed store, hash-verified

51 """
52
53 def __init__(
54 self, image: str, port: int = 8000, remove: bool = True, **kwargs
55 ):
56 super().__init__()
57
58 import docker
59
60 self.client = docker.from_env()
61 self.container: Optional[Container] = None
62
63 api_path = Path(__file__).parent / "api.py"
64 self.mounts: Dict[Path, Path] = dict()
65 self.cp: Dict[Path, Path] = {api_path: Path("/home")}
66 self.entrypoint: Dict[str, str] = dict()
67 self.tasks: List[TaskConfig] = []
68
69 self.docker_config = kwargs
70 self.image = image
71 self.port = port if port > 0 else randint(10000, 20000)
72 self.remove = remove
73
74 if not self.client.images.list(name=self.image):
75 logger.warning(
76 f"Image {self.image} not found. Pulling from Docker Hub."
77 )
78 self.client.images.pull(self.image)
79
80 def mount(self, path: str, mount_path: str) -> "DockerRuntime":
81 r"""Mount a local directory to the container.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected