anj*_*nju 5 kubernetes docker-image microk8s
我已经将一些 docker 图像导入到 microk8s 图像缓存中,以便使用本地 kubernetes 部署,
microk8s.ctr -n k8s.io image import <docker_image_name>.tar
Run Code Online (Sandbox Code Playgroud)
如何从此缓存中删除一些不需要的图像?有什么命令吗?
提前致谢!
如果要从内置库中删除所有自定义添加的图像,可以执行以下操作:
# 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 $1'} > image_ls
# loop over file, remove each image
cat image_ls | while read line || [[ -n $line ]];
do
microk8s ctr images rm $line
done;
Run Code Online (Sandbox Code Playgroud)
是的,我使用了 David Castros 的评论作为基础,但由于它不适用于 Microk8s,我需要对其进行一些调整。
也可以在一行中完成
microk8s ctr images rm $(microk8s ctr images ls name~='localhost:32000' | awk {'print $1'})
Run Code Online (Sandbox Code Playgroud)
有了--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
Run Code Online (Sandbox Code Playgroud)
所以你可以看到正在运行的容器:
microk8s.ctr -n k8s.io containers ls
Run Code Online (Sandbox Code Playgroud)
然后删除图像:
microk8s.ctr -n k8s.io images rm "image_ref"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5216 次 |
最近记录: |