This message was deleted.
# rancher-desktop
a
This message was deleted.
f
Is this using Kubernetes? kubelet has some garbage collection thresholds, and once they are reached it will delete images that are not currently in use by containers. The way to prevent this is to frequently delete build caches. Look into
docker system prune
to reclaim space.
h
I do have K8s enabled. I guess I just need to run prune more regularly. I was hoping there'd be a way to keep it from culling images I want to keep.
f
There is really not much you can do except keeping sufficient free disk space. Or to keep a container running that references the image. The behaviour is documented at Garbage Collection | Kubernetes
🙏 1
h
Claude said to create a daemonset that references the images I want to keep in initContainers. Do you think that will work?
Copy code
The initContainers force the image to be present and "used" without actually running anything.
I'm using dockerd. It said containerd has an
io.cri-containerd.pinned=pinned
label
f
I think the DaemonSet will work. Kubelet will not delete images that are in use by a running container.
You still want to avoid running out of space. When that happens you may end up in a situation for
docker system prune
no longer works and the container storage gets corrupted.
h
Thanks, good to know. I just have a couple base images I use to build others and it's annoying to have to rebuild those when then get culled.
f
Note that kubelet only deletes images; it cannot cleanup any other data. If you prune e.g. the build cache more frequently, you may have a higher chance of kubelet not triggering any image deletes.
Of course this only helps if you build different kinds of images. If you simply build the same image over and over, then deleting the build cache will just make the build go slower. Still, over time it may collect some unused artifacts that can be pruned
h
Sounds like I need to make a script for I can run when things are calm that deletes the daemonset, docker system prune, rebuild the images, and apply the daemonset. Of course, I always hit this when tracking down some other problem, and have to take a time hit while I rebuild the base images I may have built a few hours ago.