如何删除添加到 microk8s 图像缓存的 docker 个图像?
How to remove docker images added to microk8s image cache?
我已经使用
将一些 docker 图像导入到 microk8s 图像缓存中用于本地 kubernetes 部署
microk8s.ctr -n k8s.io image import <docker_image_name>.tar
如何从此缓存中删除一些不需要的图像?有什么命令吗?
提前致谢!
使用 --help
你可以看到有一个删除选项:
> microk8s.ctr -n k8s.io images --help
NAME:
ctr images - manage images
USAGE:
ctr images command [command options] [arguments...]
COMMANDS:
check check that an image has all content available locally
export export an image
import import images
list, ls list images known to containerd
pull pull an image from a remote
push push an image to a remote
remove, rm remove one or more images by reference
label set and clear labels for an image
OPTIONS:
--help, -h show help
因此您可以看到 运行 个容器:
microk8s.ctr -n k8s.io containers ls
然后删除图像:
microk8s.ctr -n k8s.io images rm "image_ref"
如果您想从内置库中删除所有自定义添加的图像,您可以这样做:
# get all images that start with localhost:32000, output the results into image_ls file
sudo microk8s ctr images ls name~='localhost:32000' | awk {'print '} > image_ls
# loop over file, remove each image
cat image_ls | while read line || [[ -n $line ]];
do
microk8s ctr images rm $line
done;
是的,我使用了 David Castros 评论作为基础,但由于它不适用于 Microk8s,我需要对其进行一些调整。
也可以一行完成
microk8s ctr images rm $(microk8s ctr images ls name~='localhost:32000' | awk {'print '})
我已经使用
将一些 docker 图像导入到 microk8s 图像缓存中用于本地 kubernetes 部署microk8s.ctr -n k8s.io image import <docker_image_name>.tar
如何从此缓存中删除一些不需要的图像?有什么命令吗?
提前致谢!
使用 --help
你可以看到有一个删除选项:
> microk8s.ctr -n k8s.io images --help
NAME:
ctr images - manage images
USAGE:
ctr images command [command options] [arguments...]
COMMANDS:
check check that an image has all content available locally
export export an image
import import images
list, ls list images known to containerd
pull pull an image from a remote
push push an image to a remote
remove, rm remove one or more images by reference
label set and clear labels for an image
OPTIONS:
--help, -h show help
因此您可以看到 运行 个容器:
microk8s.ctr -n k8s.io containers ls
然后删除图像:
microk8s.ctr -n k8s.io images rm "image_ref"
如果您想从内置库中删除所有自定义添加的图像,您可以这样做:
# get all images that start with localhost:32000, output the results into image_ls file
sudo microk8s ctr images ls name~='localhost:32000' | awk {'print '} > image_ls
# loop over file, remove each image
cat image_ls | while read line || [[ -n $line ]];
do
microk8s ctr images rm $line
done;
是的,我使用了 David Castros 评论作为基础,但由于它不适用于 Microk8s,我需要对其进行一些调整。
也可以一行完成
microk8s ctr images rm $(microk8s ctr images ls name~='localhost:32000' | awk {'print '})