From 67ec72b9cb4f13f687d661211ed9c08cdbe1c975 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:05:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=BB=98=E8=AE=A4=20Entrypoint=20=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#2638)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/container.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/app/service/container.go b/backend/app/service/container.go index 8f2085135..5d77161b4 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -327,11 +327,6 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerOperate) error { return buserr.New(constant.ErrContainerName) } - config, hostConf, networkConf, err := loadConfigInfo(true, req, nil) - if err != nil { - return err - } - global.LOG.Infof("new container info %s has been made, now start to create", req.Name) if !checkImageExist(client, req.Image) || req.ForcePull { if err := pullImages(ctx, client, req.Image); err != nil { if !req.ForcePull { @@ -340,6 +335,18 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerOperate) error { global.LOG.Errorf("force pull image %s failed, err: %v", req.Image, err) } } + imageInfo, _, err := client.ImageInspectWithRaw(ctx, req.Image) + if err != nil { + return err + } + if len(req.Entrypoint) == 0 { + req.Entrypoint = imageInfo.Config.Entrypoint + } + config, hostConf, networkConf, err := loadConfigInfo(true, req, nil) + if err != nil { + return err + } + global.LOG.Infof("new container info %s has been made, now start to create", req.Name) container, err := client.ContainerCreate(ctx, config, hostConf, networkConf, &v1.Platform{}, req.Name) if err != nil { _ = client.ContainerRemove(ctx, req.Name, types.ContainerRemoveOptions{RemoveVolumes: true, Force: true})