Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions agent/app/service/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,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(task *task.Task, client *client.Client, imageName string) error {
dockerCli := docker.NewClientWithExist(client)
options := image.PullOptions{}
Expand Down
2 changes: 1 addition & 1 deletion agent/app/service/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
switch runtime.Type {
case constant.RuntimePHP:
if runtime.Resource == constant.ResourceAppstore {
if !checkImageExist(nil, runtime.Image) {
if !checkImageLike(runtime.Image) {
return buserr.WithName("ErrImageNotExist", runtime.Name)
}
website.Proxy = fmt.Sprintf("127.0.0.1:%s", runtime.Port)
Expand Down