forked from forthfate/openorbit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.py
More file actions
36 lines (30 loc) · 1.13 KB
/
Copy pathdocker.py
File metadata and controls
36 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Linux-only Docker availability checks and safe executor configuration."""
from __future__ import annotations
import platform
import shutil
import subprocess
from dataclasses import dataclass
@dataclass(frozen=True)
class DockerStatus:
supported: bool
available: bool
reason: str
version: str | None = None
def preflight_docker() -> DockerStatus:
"""Return Docker Engine availability without creating images or containers."""
if platform.system() != "Linux":
return DockerStatus(False, False, "Docker parallel execution is supported on Linux only.")
executable = shutil.which("docker")
if not executable:
return DockerStatus(True, False, "Docker CLI is not installed or not on PATH.")
result = subprocess.run(
[executable, "version", "--format", "{{.Server.Version}}"],
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
timeout=10,
check=False,
)
if result.returncode != 0:
return DockerStatus(True, False, "Docker daemon is not reachable.")
return DockerStatus(True, True, "Docker Engine is ready.", result.stdout.strip())