Skip to content

Commit 75117a3

Browse files
authored
Merge branch 'redenfire:main' into main
2 parents 265ac2a + c6bf66a commit 75117a3

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎docker.go‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,26 @@ func getImageDigest(imageID string) (string, error) {
293293
return "", fmt.Errorf("no digest found")
294294
}
295295

296+
func resolveImageName(imageID string) string {
297+
resp, err := dockerAPI("GET", "/images/"+imageID+"/json", nil)
298+
if err != nil {
299+
return ""
300+
}
301+
defer resp.Body.Close()
302+
var data struct {
303+
RepoTags []string `json:"RepoTags"`
304+
}
305+
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
306+
return ""
307+
}
308+
for _, tag := range data.RepoTags {
309+
if tag != "<none>:<none>" {
310+
return tag
311+
}
312+
}
313+
return ""
314+
}
315+
296316
func recreateContainer(id, image string) error {
297317
inspect, err := inspectContainer(id)
298318
if err != nil {

‎main.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,13 @@ func (app *App) checkAll() {
490490
if app.selfCID != "" && c.ID[:12] == app.selfCID {
491491
continue
492492
}
493-
cleanImage := c.Image
493+
imageRef := c.Image
494+
if !strings.Contains(imageRef, "/") && !strings.Contains(imageRef, ":") {
495+
if r := resolveImageName(c.ImageID); r != "" {
496+
imageRef = r
497+
}
498+
}
499+
cleanImage := imageRef
494500
if i := strings.Index(cleanImage, "@"); i >= 0 {
495501
cleanImage = cleanImage[:i]
496502
}

0 commit comments

Comments
 (0)