mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: Fix Issue with Podman Unable to Create PHP Runtime Website (#7253)
This commit is contained in:
parent
8e3a06b07f
commit
d8fd430856
@ -983,6 +983,25 @@ func checkImageExist(client *client.Client, imageItem string) bool {
|
|||||||
return false
|
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 {
|
func pullImages(ctx context.Context, client *client.Client, imageName string) error {
|
||||||
options := image.PullOptions{}
|
options := image.PullOptions{}
|
||||||
repos, _ := imageRepoRepo.List()
|
repos, _ := imageRepoRepo.List()
|
||||||
|
@ -313,12 +313,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
|||||||
switch runtime.Type {
|
switch runtime.Type {
|
||||||
case constant.RuntimePHP:
|
case constant.RuntimePHP:
|
||||||
if runtime.Resource == constant.ResourceAppstore {
|
if runtime.Resource == constant.ResourceAppstore {
|
||||||
client, err := docker.NewDockerClient()
|
if !checkImageLike(runtime.Image) {
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer client.Close()
|
|
||||||
if !checkImageExist(client, runtime.Image) {
|
|
||||||
return buserr.WithName("ErrImageNotExist", runtime.Name)
|
return buserr.WithName("ErrImageNotExist", runtime.Name)
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user