From f4f83283d3468f2f22252daede8061f1d5be9143 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 5 May 2023 11:17:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=B9=E5=99=A8=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E6=A0=A1=E9=AA=8C=E4=BF=AE=E6=94=B9=20(#872)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/container.go | 11 ++++++++--- .../src/views/container/container/create/index.vue | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/app/service/container.go b/backend/app/service/container.go index 26a9e128f..ca717abaa 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -418,8 +418,8 @@ func checkPortStats(ports []dto.PortHelper) (nat.PortMap, error) { return portMap, nil } for _, port := range ports { - if strings.Contains(port.HostPort, "-") { - if !strings.Contains(port.ContainerPort, "-") { + if strings.Contains(port.ContainerPort, "-") { + if !strings.Contains(port.HostPort, "-") { return portMap, buserr.New(constant.ErrPortRules) } hostStart, _ := strconv.Atoi(strings.Split(port.HostPort, "-")[0]) @@ -442,7 +442,12 @@ func checkPortStats(ports []dto.PortHelper) (nat.PortMap, error) { } } } else { - portItem, _ := strconv.Atoi(port.HostPort) + portItem := 0 + if strings.Contains(port.HostPort, "-") { + portItem, _ = strconv.Atoi(strings.Split(port.HostPort, "-")[0]) + } else { + portItem, _ = strconv.Atoi(port.HostPort) + } if common.ScanPort(portItem) { return portMap, buserr.WithDetail(constant.ErrPortInUsed, portItem, nil) } diff --git a/frontend/src/views/container/container/create/index.vue b/frontend/src/views/container/container/create/index.vue index 51cdf4e3d..2ef9daf66 100644 --- a/frontend/src/views/container/container/create/index.vue +++ b/frontend/src/views/container/container/create/index.vue @@ -58,7 +58,7 @@ - +