mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: 容器创建增加 entrypoint 参数 (#2217)
This commit is contained in:
parent
ad8bf09034
commit
9a43b52c62
@ -45,6 +45,7 @@ type ContainerOperate struct {
|
||||
PublishAllPorts bool `json:"publishAllPorts"`
|
||||
ExposedPorts []PortHelper `json:"exposedPorts"`
|
||||
Cmd []string `json:"cmd"`
|
||||
Entrypoint []string `json:"entrypoint"`
|
||||
CPUShares int64 `json:"cpuShares"`
|
||||
NanoCPUs float64 `json:"nanoCPUs"`
|
||||
Memory float64 `json:"memory"`
|
||||
|
@ -366,6 +366,7 @@ func (u *ContainerService) ContainerInfo(req dto.OperationWithName) (*dto.Contai
|
||||
}
|
||||
}
|
||||
data.Cmd = oldContainer.Config.Cmd
|
||||
data.Entrypoint = oldContainer.Config.Entrypoint
|
||||
data.Env = oldContainer.Config.Env
|
||||
data.CPUShares = oldContainer.HostConfig.CPUShares
|
||||
for key, val := range oldContainer.Config.Labels {
|
||||
@ -842,6 +843,7 @@ func loadConfigInfo(req dto.ContainerOperate, config *container.Config, hostConf
|
||||
}
|
||||
config.Image = req.Image
|
||||
config.Cmd = req.Cmd
|
||||
config.Entrypoint = req.Entrypoint
|
||||
config.Env = req.Env
|
||||
config.Labels = stringsToMap(req.Labels)
|
||||
config.ExposedPorts = exposeds
|
||||
|
@ -23,8 +23,10 @@ export namespace Container {
|
||||
forcePull: boolean;
|
||||
network: string;
|
||||
cmdStr: string;
|
||||
entrypointStr: string;
|
||||
memoryItem: number;
|
||||
cmd: Array<string>;
|
||||
entrypoint: Array<string>;
|
||||
publishAllPorts: boolean;
|
||||
exposedPorts: Array<Port>;
|
||||
nanoCPUs: number;
|
||||
|
@ -543,8 +543,8 @@ const message = {
|
||||
containerExample: 'e.g. 80 or 80-88',
|
||||
exposePort: 'Expose port',
|
||||
exposeAll: 'Expose all',
|
||||
cmd: 'Command',
|
||||
cmdHelper: "Separate multiple commands with ' ' as delimiter, such as 'nginx' '-g' 'daemon off;'",
|
||||
cmdHelper: "e.g. 'nginx' '-g' 'daemon off;' OR nginx -g daemon off;",
|
||||
entrypointHelper: 'e.g. /bin/sh -c',
|
||||
autoRemove: 'Auto remove',
|
||||
cpuQuota: 'NacosCPU',
|
||||
memoryLimit: 'Memory',
|
||||
|
@ -527,8 +527,8 @@ const message = {
|
||||
containerExample: '例: 80 或者 80-88',
|
||||
exposePort: '暴露端口',
|
||||
exposeAll: '暴露所有',
|
||||
cmd: '啟動命令',
|
||||
cmdHelper: "多個命令間請用 ' ' 分隔開,如 'nginx' '-g' 'daemon off;'",
|
||||
cmdHelper: "例: 'nginx' '-g' 'daemon off;' 或 nginx -g daemon off;",
|
||||
entrypointHelper: '例: /bin/sh -c',
|
||||
autoRemove: '容器退出後自動刪除容器',
|
||||
cpuQuota: 'CPU 限製',
|
||||
memoryLimit: '內存限製',
|
||||
|
@ -527,8 +527,8 @@ const message = {
|
||||
containerExample: '例: 80 或者 80-88',
|
||||
exposePort: '暴露端口',
|
||||
exposeAll: '暴露所有',
|
||||
cmd: '启动命令',
|
||||
cmdHelper: "多个命令间请用 ' ' 分隔开,如 'nginx' '-g' 'daemon off;'",
|
||||
cmdHelper: "例: 'nginx' '-g' 'daemon off;' 或者 nginx -g daemon off;",
|
||||
entrypointHelper: '例: /bin/sh -c',
|
||||
autoRemove: '容器退出后自动删除容器',
|
||||
cpuQuota: 'CPU 限制',
|
||||
memoryLimit: '内存限制',
|
||||
|
@ -109,39 +109,6 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.cmd')" prop="cmdStr">
|
||||
<el-input v-model="dialogData.rowData!.cmdStr" />
|
||||
<span class="input-help">{{ $t('container.cmdHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item prop="autoRemove">
|
||||
<el-checkbox v-model="dialogData.rowData!.autoRemove">
|
||||
{{ $t('container.autoRemove') }}
|
||||
</el-checkbox>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.cpuShare')" prop="cpuShares">
|
||||
<el-input class="mini-form-item" v-model.number="dialogData.rowData!.cpuShares" />
|
||||
<span class="input-help">{{ $t('container.cpuShareHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$t('container.cpuQuota')"
|
||||
prop="nanoCPUs"
|
||||
:rules="checkFloatNumberRange(0, Number(limits.cpu))"
|
||||
>
|
||||
<el-input class="mini-form-item" v-model="dialogData.rowData!.nanoCPUs">
|
||||
<template #append>
|
||||
<div style="width: 35px">{{ $t('commons.units.core') }}</div>
|
||||
</template>
|
||||
</el-input>
|
||||
<span class="input-help">
|
||||
{{ $t('container.limitHelper', [limits.cpu]) }}{{ $t('commons.units.core') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.memoryLimit')" prop="memory">
|
||||
<el-input class="mini-form-item" v-model="dialogData.rowData!.memory">
|
||||
<template #append><div style="width: 35px">MB</div></template>
|
||||
</el-input>
|
||||
<span class="input-help">{{ $t('container.limitHelper', [limits.memory]) }}MB</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.mount')">
|
||||
<el-card style="width: 100%">
|
||||
<table style="width: 100%" class="tab-table">
|
||||
@ -167,12 +134,14 @@
|
||||
filterable
|
||||
v-model="row.sourceDir"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, indexV) of volumes"
|
||||
:key="indexV"
|
||||
:value="item.option"
|
||||
:label="item.option.substring(0, 12)"
|
||||
/>
|
||||
<div v-for="(item, indexV) of volumes" :key="indexV">
|
||||
<el-tooltip :hide-after="20" :content="item.option" placement="top">
|
||||
<el-option
|
||||
:value="item.option"
|
||||
:label="item.option.substring(0, 12)"
|
||||
/>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</el-select>
|
||||
</td>
|
||||
<td width="18%">
|
||||
@ -200,6 +169,52 @@
|
||||
</table>
|
||||
</el-card>
|
||||
</el-form-item>
|
||||
<el-form-item label="Command" prop="cmdStr">
|
||||
<el-input v-model="dialogData.rowData!.cmdStr" :placeholder="$t('container.cmdHelper')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Entrypoint" prop="entrypoint">
|
||||
<el-input
|
||||
v-model="dialogData.rowData!.entrypointStr"
|
||||
:placeholder="$t('container.entrypointHelper')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item prop="autoRemove">
|
||||
<el-checkbox v-model="dialogData.rowData!.autoRemove">
|
||||
{{ $t('container.autoRemove') }}
|
||||
</el-checkbox>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.restartPolicy')" prop="restartPolicy">
|
||||
<el-radio-group v-model="dialogData.rowData!.restartPolicy">
|
||||
<el-radio label="no">{{ $t('container.no') }}</el-radio>
|
||||
<el-radio label="always">{{ $t('container.always') }}</el-radio>
|
||||
<el-radio label="on-failure">{{ $t('container.onFailure') }}</el-radio>
|
||||
<el-radio label="unless-stopped">{{ $t('container.unlessStopped') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.cpuShare')" prop="cpuShares">
|
||||
<el-input class="mini-form-item" v-model.number="dialogData.rowData!.cpuShares" />
|
||||
<span class="input-help">{{ $t('container.cpuShareHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$t('container.cpuQuota')"
|
||||
prop="nanoCPUs"
|
||||
:rules="checkFloatNumberRange(0, Number(limits.cpu))"
|
||||
>
|
||||
<el-input class="mini-form-item" v-model="dialogData.rowData!.nanoCPUs">
|
||||
<template #append>
|
||||
<div style="width: 35px">{{ $t('commons.units.core') }}</div>
|
||||
</template>
|
||||
</el-input>
|
||||
<span class="input-help">
|
||||
{{ $t('container.limitHelper', [limits.cpu]) }}{{ $t('commons.units.core') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.memoryLimit')" prop="memory">
|
||||
<el-input class="mini-form-item" v-model="dialogData.rowData!.memory">
|
||||
<template #append><div style="width: 35px">MB</div></template>
|
||||
</el-input>
|
||||
<span class="input-help">{{ $t('container.limitHelper', [limits.memory]) }}MB</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.tag')" prop="labelsStr">
|
||||
<el-input
|
||||
type="textarea"
|
||||
@ -216,14 +231,6 @@
|
||||
v-model="dialogData.rowData!.envStr"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.restartPolicy')" prop="restartPolicy">
|
||||
<el-radio-group v-model="dialogData.rowData!.restartPolicy">
|
||||
<el-radio label="no">{{ $t('container.no') }}</el-radio>
|
||||
<el-radio label="always">{{ $t('container.always') }}</el-radio>
|
||||
<el-radio label="on-failure">{{ $t('container.onFailure') }}</el-radio>
|
||||
<el-radio label="unless-stopped">{{ $t('container.unlessStopped') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
@ -282,6 +289,9 @@ const acceptParams = (params: DialogProps): void => {
|
||||
itemCmd += `'${item}' `;
|
||||
}
|
||||
dialogData.value.rowData.cmdStr = itemCmd ? itemCmd.substring(0, itemCmd.length - 1) : '';
|
||||
if (dialogData.value.rowData.entrypoint) {
|
||||
dialogData.value.rowData.entrypointStr = dialogData.value.rowData.entrypoint.join(' ');
|
||||
}
|
||||
dialogData.value.rowData.labels = dialogData.value.rowData.labels || [];
|
||||
dialogData.value.rowData.env = dialogData.value.rowData.env || [];
|
||||
dialogData.value.rowData.labelsStr = dialogData.value.rowData.labels.join('\n');
|
||||
@ -391,13 +401,21 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
dialogData.value.rowData!.labels = dialogData.value.rowData!.labelsStr.split('\n');
|
||||
}
|
||||
dialogData.value.rowData!.cmd = [];
|
||||
if (dialogData.value.rowData?.cmdStr) {
|
||||
if (dialogData.value.rowData?.cmdStr.indexOf(`'`) !== -1) {
|
||||
let itemCmd = dialogData.value.rowData!.cmdStr.split(`'`);
|
||||
for (const cmd of itemCmd) {
|
||||
if (cmd && cmd !== ' ') {
|
||||
dialogData.value.rowData!.cmd.push(cmd);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let itemCmd = dialogData.value.rowData!.cmdStr.split(` `);
|
||||
for (const cmd of itemCmd) {
|
||||
dialogData.value.rowData!.cmd.push(cmd);
|
||||
}
|
||||
}
|
||||
if (dialogData.value.rowData!.entrypointStr) {
|
||||
dialogData.value.rowData!.entrypoint = dialogData.value.rowData!.entrypointStr.split(' ');
|
||||
}
|
||||
if (!checkPortValid()) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user