fix: 创建容器失败时,删除失败容器

This commit is contained in:
ssongliu 2022-12-02 14:09:30 +08:00
parent 9fcd3c78e1
commit 614570a4c7
2 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -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 });
}