From cf1d02771f5cda703713f8b0fb8e0e43a6d4ebcd Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:42:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20Docker=20=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#6805?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/docker.go | 3 +++ backend/utils/cmd/cmd.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/app/service/docker.go b/backend/app/service/docker.go index b9cea2543..920657fff 100644 --- a/backend/app/service/docker.go +++ b/backend/app/service/docker.go @@ -426,6 +426,9 @@ func changeLogOption(daemonMap map[string]interface{}, logMaxFile, logMaxSize st } func validateDockerConfig() error { + if !cmd.Which("dockerd") { + return nil + } stdout, err := cmd.Exec("dockerd --validate") if err != nil || (stdout != "" && strings.TrimSpace(stdout) != "configuration OK") { return fmt.Errorf("Docker configuration validation failed, err: %v", stdout) diff --git a/backend/utils/cmd/cmd.go b/backend/utils/cmd/cmd.go index 46b20fc1f..cfadd3670 100644 --- a/backend/utils/cmd/cmd.go +++ b/backend/utils/cmd/cmd.go @@ -204,7 +204,7 @@ func SudoHandleCmd() string { func Which(name string) bool { stdout, err := Execf("which %s", name) - if err != nil || (len(strings.ReplaceAll(stdout, "\n", "")) == 0 && strings.HasPrefix(stdout, "/")) { + if err != nil || (len(strings.ReplaceAll(stdout, "\n", "")) == 0) { return false } return true