mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-23 22:34:10 +08:00
fix: 容器创建增加端口判断
This commit is contained in:
parent
eb56b918a6
commit
2dec0bfb3c
2 changed files with 11 additions and 2 deletions
|
@ -12,8 +12,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
|
@ -136,6 +138,13 @@ func (u *ContainerService) Inspect(req dto.InspectReq) (string, error) {
|
|||
}
|
||||
|
||||
func (u *ContainerService) ContainerCreate(req dto.ContainerCreate) error {
|
||||
if len(req.ExposedPorts) != 0 {
|
||||
for _, port := range req.ExposedPorts {
|
||||
if common.ScanPort(port.HostPort) {
|
||||
return buserr.WithDetail(constant.ErrPortInUsed, port.HostPort, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
client, err := docker.NewDockerClient()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<el-form-item :label="$t('container.cpuQuota')" prop="nanoCPUs">
|
||||
<el-input type="number" style="width: 40%" v-model.number="form.nanoCPUs">
|
||||
<template #append>
|
||||
<el-select v-model="form.cpuUnit" disabled style="width: 65px">
|
||||
<el-select v-model="form.cpuUnit" disabled style="width: 85px">
|
||||
<el-option label="Core" value="Core" />
|
||||
</el-select>
|
||||
</template>
|
||||
|
@ -94,7 +94,7 @@
|
|||
<el-form-item :label="$t('container.memoryLimit')" prop="memoryItem">
|
||||
<el-input style="width: 40%" v-model.number="form.memoryItem">
|
||||
<template #append>
|
||||
<el-select v-model="form.memoryUnit" placeholder="Select" style="width: 65px">
|
||||
<el-select v-model="form.memoryUnit" placeholder="Select" style="width: 85px">
|
||||
<el-option label="KB" value="KB" />
|
||||
<el-option label="MB" value="MB" />
|
||||
<el-option label="GB" value="GB" />
|
||||
|
|
Loading…
Reference in a new issue