mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 06:32:59 +08:00
fix: 创建容器失败时,删除失败容器
This commit is contained in:
parent
9fcd3c78e1
commit
614570a4c7
@ -157,9 +157,11 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerCreate) error {
|
||||
}
|
||||
container, err := client.ContainerCreate(context.TODO(), config, hostConf, &network.NetworkingConfig{}, &v1.Platform{}, req.Name)
|
||||
if err != nil {
|
||||
_ = client.ContainerRemove(context.Background(), req.Name, types.ContainerRemoveOptions{RemoveVolumes: true, Force: true})
|
||||
return err
|
||||
}
|
||||
if err := client.ContainerStart(context.TODO(), container.ID, types.ContainerStartOptions{}); err != nil {
|
||||
_ = client.ContainerRemove(context.Background(), req.Name, types.ContainerRemoveOptions{RemoveVolumes: true, Force: true})
|
||||
return fmt.Errorf("create successful but start failed, err: %v", err)
|
||||
}
|
||||
return nil
|
||||
|
@ -298,6 +298,9 @@ const loadBackups = async () => {
|
||||
for (const item of res.data) {
|
||||
if (item.type === 'LOCAL') {
|
||||
localDirID.value = item.id;
|
||||
if (!dialogData.value.rowData!.targetDirID) {
|
||||
dialogData.value.rowData!.targetDirID = item.id;
|
||||
}
|
||||
}
|
||||
backupOptions.value.push({ label: loadBackupName(item.type), value: item.id });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user