Pulizia: dice quali nomi image prune -a toglie alle immagini in uso

Docker non toglie un'immagine che un contenitore usa, ma con -a le toglie
i nomi in più: con lo store classico tutti tranne l'ultimo in ordine
alfabetico, anche quello da cui il contenitore è stato creato
(un'applicazione di Unraid creata da app:1.2 che si chiama anche
app:latest resta senza app:1.2); con containerd tutti tranne quelli dei
contenitori. La prova saltava ogni immagine in uso e i documenti la
davano per intoccata (rilievo della revisione, controllato sul codice di
moby v24, v27 e master).

La pulizia vera confronta i nomi prima e dopo la potatura e scrive, nome
per nome, quelli tolti a un'immagine che resta; la prova li stima secondo
lo store e li conta, e le prove controllano che stima e pulizia vera
coincidano con l'uno e con l'altro store. Il comando resta quello
chiesto, docker image prune -a -f --filter until=24h; docs/processo.md e
docs/docker.md dicono che cosa succede ai nomi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-21 11:56:41 +02:00
1 parent e24ebd24f0
commit 68100b0295
7 files changed
+233 -40

No files matched your search

@@ -276,6 +276,16 @@ public sealed partial class PipelineTests
CollectionAssert.AreEquivalent(SharedDaemon.VolumesLeft, run.Volumes, run.Report);
CollectionAssert.AreEquivalent(SharedDaemon.NetworksLeft, run.Networks, run.Report);
// An image a container uses stays, but «image prune -a» takes its extra names: with the classic store all but
// the last in the order of their full names, even the one the container was made from (Jellyfin, from :10.9).
// The log says so, name by name.
StringAssert.Contains(run.Output, "== Store delle immagini del demone: classico", run.Report);
CollectionAssert.Contains(run.Images, "img-rilascio|192.168.30.23:3000/alby96/febe:latest", run.Report);
CollectionAssert.Contains(run.Images, "img-jellyfin|jellyfin/jellyfin:latest", run.Report);
StringAssert.Contains(run.Output, " tolto il nome jellyfin/jellyfin:10.9; l'immagine img-jellyfin resta\n", run.Report);
StringAssert.Contains(run.Output, " tolto il nome 192.168.30.23:3000/alby96/febe:0.1.0; l'immagine img-rilascio resta\n", run.Report);
Assert.AreEqual("2", SummaryCount(run.Output, "nomi tolti a immagini che restano"), run.Report);
// Not even an attempt on what is not the CI's (Docker would refuse some of it: the script must not ask), and
// the prunes of everyone only with their filter, once.
foreach (var call in run.Calls)
@@ -341,6 +351,8 @@ public sealed partial class PipelineTests
" toglierei 192.168.30.23:3000/alby96/febe:0.0.9 (img-febe-vec) · 400MB · creata 34 giorni fa\n",
" toglierei node:24-trixie (img-node) · 410MB · creata 13 giorni fa\n",
" toglierei un'immagine senza nome (img-plex-pre) · 300MB · creata 69 giorni fa\n",
" toglierei il nome 192.168.30.23:3000/alby96/febe:0.1.0; l'immagine img-rilascio resta, perché la usa un contenitore\n",
" toglierei il nome jellyfin/jellyfin:10.9; l'immagine img-jellyfin resta, perché la usa un contenitore\n",
"la cache di costruzione del demone occupa 5.3GB",
" toglierei sha-4e5f6a7 (pubblicata il 2026-10-05T01:00:00+02:00)\n",
$" {UntaggedDigests.Length} versioni senza etichetta (sha256:…",
@@ -350,7 +362,7 @@ public sealed partial class PipelineTests
StringAssert.Contains(tried.Output, expected, tried.Report);
}
foreach (var kept in new[] { "plexinc/pms-docker", "encelado:latest", "mimante:latest", "runner-images", "moby/buildkit", "act-toolcache", "encelado-dati", "febe:latest", "toglierei main", "toglierei latest", "toglierei 0.1.", "GITEA-ACTIONS-TASK-90", "GITEA-ACTIONS-TASK-60", "GITEA-ACTIONS-TASK-88", "GITEA-ACTIONS-TASK-89", "GITEA-ACTIONS-TASK-77" })
foreach (var kept in new[] { "plexinc/pms-docker", "encelado:latest", "mimante:latest", "runner-images", "moby/buildkit", "act-toolcache", "encelado-dati", "febe:latest", "jellyfin/jellyfin:latest", "toglierei main", "toglierei latest", "toglierei 0.1.", "GITEA-ACTIONS-TASK-90", "GITEA-ACTIONS-TASK-60", "GITEA-ACTIONS-TASK-88", "GITEA-ACTIONS-TASK-89", "GITEA-ACTIONS-TASK-77" })
{
Assert.DoesNotContain(kept, tried.Output, tried.Report);
}
@@ -358,7 +370,7 @@ public sealed partial class PipelineTests
// And it counts what the real cleanup then takes.
var real = await RunCleanupAsync(bash, world, "completa");
Assert.AreEqual(0, real.Code, real.Report);
foreach (var kind in new[] { "contenitori di prova della CI di Febe", "immagini febe-ci", "builder buildx della CI di Febe", "contenitori fermi di act_runner", "volumi di act_runner", "reti di act_runner", "immagini che nessun contenitore usa", "etichette sha- sul registro" })
foreach (var kind in new[] { "contenitori di prova della CI di Febe", "immagini febe-ci", "builder buildx della CI di Febe", "contenitori fermi di act_runner", "volumi di act_runner", "reti di act_runner", "immagini che nessun contenitore usa", "nomi tolti a immagini che restano", "etichette sha- sul registro" })
{
Assert.AreEqual(SummaryCount(real.Output, kind), SummaryCount(tried.Output, kind), $"{kind}\n{tried.Report}\n{real.Report}");
}
@@ -371,11 +383,28 @@ public sealed partial class PipelineTests
// With the containerd image store «until» counts from when a name reached the daemon, which no command shows;
// the dry run can only give the age of the image and must say so.
var bash = RequireBash();
var tried = await RunCleanupAsync(bash, SharedDaemon.World with { Store = "containerd" }, "completa", "--prova");
var world = SharedDaemon.World with { Store = "containerd" };
var tried = await RunCleanupAsync(bash, world, "completa", "--prova");
Assert.AreEqual(0, tried.Code, tried.Report);
StringAssert.Contains(tried.Output, "== Store delle immagini del demone: containerd (le 24 ore contano da quando un nome è arrivato sul demone)\n", tried.Report);
StringAssert.Contains(tried.Output, "l'elenco è solo indicativo)", tried.Report);
CollectionAssert.Contains(tried.Calls, "BUILDX_BUILDER=default docker info --format {{json .DriverStatus}}", "the store is read, never changed");
// Of an image a container uses, containerd keeps the names the containers were made from and takes the others:
// Jellyfin keeps :10.9 and loses :latest, the other way round from the classic store. The dry run says so, and
// the real cleanup does it.
StringAssert.Contains(tried.Output, " toglierei il nome jellyfin/jellyfin:latest; l'immagine img-jellyfin resta, perché la usa un contenitore\n", tried.Report);
StringAssert.Contains(tried.Output, " toglierei il nome 192.168.30.23:3000/alby96/febe:0.1.0; l'immagine img-rilascio resta, perché la usa un contenitore\n", tried.Report);
Assert.DoesNotContain("jellyfin/jellyfin:10.9", tried.Output, tried.Report);
var real = await RunCleanupAsync(bash, world, "completa");
Assert.AreEqual(0, real.Code, real.Report);
CollectionAssert.AreEquivalent(SharedDaemon.ImagesLeft, real.ImageIds, real.Report);
CollectionAssert.Contains(real.Images, "img-jellyfin|jellyfin/jellyfin:10.9", real.Report);
CollectionAssert.Contains(real.Images, "img-rilascio|192.168.30.23:3000/alby96/febe:latest", real.Report);
foreach (var kind in new[] { "immagini che nessun contenitore usa", "nomi tolti a immagini che restano" })
{
Assert.AreEqual(SummaryCount(real.Output, kind), SummaryCount(tried.Output, kind), $"{kind}\n{tried.Report}\n{real.Report}");
}
}
[TestMethod]
@@ -552,7 +581,8 @@ public sealed partial class PipelineTests
/// A daemon as the runner's is likely to be (format in fake-docker.sh): a real Febe and Unraid apps, running and
/// stopped; the job container of the cleanup itself; leftovers of act_runner, with the names of today's act_runner
/// («_WORKFLOW-…») and of older ones («-WORKFLOW-…» with a hash), and look-alikes; leftovers of the CI of Febe;
/// images used and unused, named and dangling, old and young; volumes and networks of every kind.
/// images used and unused, named and dangling, old and young; volumes and networks of every kind. The images of the
/// real Febe and of Jellyfin have two names each, and Jellyfin was created from the one that is not the last.
/// </summary>
private static class SharedDaemon
{
@@ -564,6 +594,7 @@ public sealed partial class PipelineTests
[
"c-febe-vero|febe|running|43200|192.168.30.23:3000/alby96/febe:latest|img-rilascio|febe.ci.workflow=rilascio,febe.ci.run=777,febe.ci.ref=v0.1.0|febe-dati|bridge",
"c-plex|plex|exited|90000|plexinc/pms-docker:latest|img-plex||plex-config|br0",
"c-jellyfin|jellyfin|running|90000|jellyfin/jellyfin:10.9|img-jellyfin||",
"c-encelado|encelado|exited|5000|encelado:latest|img-encelado|||encelado_default",
$"c-lavoro|{Job90}|running|5|docker.gitea.com/runner-images:ubuntu-latest|img-runner||{Job90},{Job90}-env,act-toolcache|{Job90}-docker-network",
$"c-act-fermo|{Job53}|exited|3000|node:24-trixie|img-node||{Job53},{Job53}-env,act-toolcache|{Job53}-prove-network",
@@ -584,6 +615,7 @@ public sealed partial class PipelineTests
"img-febe-vecchia|192.168.30.23:3000/alby96/febe:0.0.9|50000||400MB",
"img-plex|plexinc/pms-docker:latest|100000||300MB",
"img-plex-precedente||100000||300MB",
"img-jellyfin|jellyfin/jellyfin:10.9,jellyfin/jellyfin:latest|100000||900MB",
"img-encelado|encelado:latest|5000||250MB",
"img-encelado-dev|encelado:dev|3000||250MB",
"img-mimante-nuova|mimante:latest|60||180MB",