MCPcopy Create free account
hub / github.com/github/gh-aw / isDockerDaemonRunning

Function isDockerDaemonRunning

pkg/workflow/docker_validation.go:71–90  ·  view source on GitHub ↗

isDockerDaemonRunning checks if the Docker daemon is responsive. Uses a short timeout to avoid hanging when Docker is installed but the daemon is stopped. Results are cached via dockerDaemonLoader; the cached value can be overridden by markDockerDaemonUnavailable when a later docker command detects

()

Source from the content-addressed store, hash-verified

69// Results are cached via dockerDaemonLoader; the cached value can be overridden by
70// markDockerDaemonUnavailable when a later docker command detects the daemon is unreachable.
71func isDockerDaemonRunning() bool {
72 available, _ := dockerDaemonLoader.Get(func() (bool, error) {
73 dockerValidationLog.Print("Checking if Docker daemon is running")
74 ctx, cancel := context.WithTimeout(context.Background(), dockerDaemonCheckTimeout)
75 defer cancel()
76
77 cmd := exec.CommandContext(ctx, "docker", "info")
78 cmd.Stdout = nil
79 cmd.Stderr = nil
80 err := cmd.Run()
81
82 if err != nil {
83 dockerValidationLog.Printf("Docker daemon not running or not responsive: %v", err)
84 return false, nil //nolint:nilerr // intentional: cache false without an error
85 }
86 dockerValidationLog.Print("Docker daemon is running")
87 return true, nil
88 })
89 return available
90}
91
92// markDockerDaemonUnavailable records that the Docker daemon is not reachable.
93// Subsequent calls to isDockerDaemonRunning will return false immediately, so

Calls 5

PrintMethod · 0.80
BackgroundMethod · 0.80
GetMethod · 0.45
RunMethod · 0.45
PrintfMethod · 0.45