I’m getting a low disk space warning on a server where my microk8s and applications are installed. When I run the microk8s ctr image ls command, multiple images appear for an application. Does the "docker image prune -f" command in Docker have an equivalent in microk8s? Or is there a way possible?
3
Answers
If you want to delete all custom added images from the built-in library, you can do this:
Put it into a .sh file and run the script
You can use
crictl
to prune unused images sincecrictl
is compatible with containerdcrictl
using this https://github.com/kubernetes-sigs/cri-tools/blob/edf14e37007994d69f9b8cb3b1483a79b365b8eb/docs/crictl.md#install-crictlcrictl
is working using microk8s containerdsudo crictl --runtime-endpoint unix:///var/snap/microk8s/common/run/containerd.sock images
sudo crictl --runtime-endpoint unix:///var/snap/microk8s/common/run/containerd.sock rmi --prune
The docs said that you can also use
CONTAINER_RUNTIME_ENDPOINT
but I can’t to get that working.Update:
You can also use config file, add below to /etc/crictl.yaml:
A one liner:
You can remove the filter
name~='localhost:32000'
or use it to match specific tag you want to clean up, example:name~=':v5.2.0'
.NOTE: If no filter is specified, all local images will be removed