From 241a4e62aca022cbe21044aa2eedd0c9623e3f14 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Sun, 9 Apr 2023 23:58:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=B9=E5=99=A8=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=20(#553)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/docker.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/app/service/docker.go b/backend/app/service/docker.go index cb41b7696..cc51271f9 100644 --- a/backend/app/service/docker.go +++ b/backend/app/service/docker.go @@ -156,6 +156,10 @@ func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error { deamonMap["exec-opts"] = []string{"native.cgroupdriver=systemd"} } } + if len(deamonMap) == 0 { + _ = os.Remove(constant.DaemonJsonPath) + return nil + } newJson, err := json.MarshalIndent(deamonMap, "", "\t") if err != nil { return err @@ -172,6 +176,10 @@ func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error { } func (u *DockerService) UpdateConfByFile(req dto.DaemonJsonUpdateByFile) error { + if len(req.File) == 0 { + _ = os.Remove(constant.DaemonJsonPath) + return nil + } if _, err := os.Stat(constant.DaemonJsonPath); err != nil && os.IsNotExist(err) { if err = os.MkdirAll(path.Dir(constant.DaemonJsonPath), os.ModePerm); err != nil { return err