@@ -12,6 +12,7 @@ import (
1212 "time"
1313
1414 "github.com/1Panel-dev/1Panel/agent/app/repo"
15+ "github.com/docker/docker/api/types/image"
1516
1617 "github.com/1Panel-dev/1Panel/agent/app/dto"
1718 "github.com/1Panel-dev/1Panel/agent/app/model"
@@ -23,6 +24,7 @@ import (
2324 "github.com/1Panel-dev/1Panel/agent/utils/common"
2425 "github.com/1Panel-dev/1Panel/agent/utils/controller"
2526 "github.com/1Panel-dev/1Panel/agent/utils/copier"
27+ "github.com/1Panel-dev/1Panel/agent/utils/docker"
2628 "github.com/1Panel-dev/1Panel/agent/utils/files"
2729 "gorm.io/gorm"
2830)
@@ -369,9 +371,21 @@ func snapAppImage(snap snapHelper, req dto.SnapshotCreate, targetDir string) err
369371 }
370372 }
371373
374+ client , err := docker .NewDockerClient ()
375+ if err != nil {
376+ snap .Task .Log ("load docker client failed, skip save app images" )
377+ return nil
378+ }
379+ images , err := client .ImageList (context .Background (), image.ListOptions {})
380+ if err != nil {
381+ snap .Task .Log ("list docker images failed, skip save app images" )
382+ return nil
383+ }
384+ var existImages []string
385+ for _ , img := range images {
386+ existImages = append (existImages , img .RepoTags ... )
387+ }
372388 var imageList []string
373- existStr , _ := cmd .RunDefaultWithStdoutBashC ("docker images | awk '{print $1\" :\" $2}' | grep -v REPOSITORY:TAG" )
374- existImages := strings .Split (existStr , "\n " )
375389 for _ , app := range req .AppData {
376390 for _ , item := range app .Children {
377391 if item .Label == "appImage" && item .IsCheck {
0 commit comments