docker: remove images no container or declaration uses, keeping the previous of each line (hq ADR 0251)

Images pulled by digest are not dangling, so the weekly prune never takes an old version
and every machine keeps every image it ever ran. docker_prune_images takes them, keeps what
the declaration names (asked of the controller; no answer, nothing removed) and the one before,
and is a dry run unless asked with a why.
This commit is contained in:
jochen
2026-10-08 11:56:36 +02:00
parent f7b1853b8b
commit 2665693bb3
7 changed files with 737 additions and 1 deletions
+6 -1
View File
@@ -20,6 +20,8 @@ import (
"strconv"
"strings"
"time"
stdio "git.novox.be/novox/mesh-sdk/go"
)
// MeshLabel is the label the host puts on every container it creates (mesh-host internal/apply).
@@ -34,11 +36,14 @@ type Client struct {
UID int
ReadFile func(string) ([]byte, error)
Now func() time.Time
// Ask asks the mesh (the SDK's stdio.Ask); Node is this machine's name (MESH_NODE).
Ask Asker
Node string
}
// NewClient is the client the bundle serves with.
func NewClient() *Client {
return &Client{Run: ExecRunner, UID: os.Getuid(), ReadFile: os.ReadFile, Now: time.Now}
return &Client{Run: ExecRunner, UID: os.Getuid(), ReadFile: os.ReadFile, Now: time.Now, Ask: stdio.Ask, Node: os.Getenv("MESH_NODE")}
}
var socketRefused = regexp.MustCompile(`(?i)permission denied.*docker.*sock|docker\.sock.*permission denied`)