diff --git a/backend/app/service/container.go b/backend/app/service/container.go index b7a3ab96b..b38da965d 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -983,6 +983,25 @@ func checkImageExist(client *client.Client, imageItem string) bool { return false } +func checkImageLike(imageName string) bool { + cli, err := docker.NewDockerClient() + if err != nil { + return false + } + images, err := cli.ImageList(context.Background(), image.ListOptions{}) + if err != nil { + return false + } + for _, img := range images { + for _, tag := range img.RepoTags { + if strings.Contains(tag, imageName) { + return true + } + } + } + return false +} + func pullImages(ctx context.Context, client *client.Client, imageName string) error { options := image.PullOptions{} repos, _ := imageRepoRepo.List() diff --git a/backend/app/service/website.go b/backend/app/service/website.go index 648914cb2..2ee218215 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -313,12 +313,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error) switch runtime.Type { case constant.RuntimePHP: if runtime.Resource == constant.ResourceAppstore { - client, err := docker.NewDockerClient() - if err != nil { - return err - } - defer client.Close() - if !checkImageExist(client, runtime.Image) { + if !checkImageLike(runtime.Image) { return buserr.WithName("ErrImageNotExist", runtime.Name) } var (