MCPcopy Create free account
hub / github.com/QuantGeekDev/docker-mcp / DockerExecutorBase

Class DockerExecutorBase

src/docker_mcp/docker_executor.py:37–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36
37class DockerExecutorBase(ABC):
38 def __init__(self):
39 self.docker_cmd = self._initialize_docker_cmd()
40 self.executor = WindowsExecutor() if platform.system() == 'Windows' else UnixExecutor()
41
42 @abstractmethod
43 async def run_command(self, command: str, *args) -> Tuple[int, str, str]:
44 pass
45
46 def _initialize_docker_cmd(self) -> str:
47 if platform.system() == 'Windows':
48 docker_dir = r"C:\Program Files\Docker\Docker\resources\bin"
49 docker_paths = [
50 os.path.join(docker_dir, "docker-compose.exe"),
51 os.path.join(docker_dir, "docker.exe")
52 ]
53 for path in docker_paths:
54 if os.path.exists(path):
55 return path
56
57 docker_cmd = shutil.which('docker')
58 if not docker_cmd:
59 raise RuntimeError("Docker executable not found")
60 return docker_cmd
61
62
63class DockerComposeExecutor(DockerExecutorBase):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected