配置 containerd
镜像源
- 打开
/etc/containerd/config.toml
:
sudo vim /etc/containerd/config.toml
- 找到
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
,添加私有镜像库配置:
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://registry.cn-beijing.aliyuncs.com"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
endpoint = ["https://registry.cn-beijing.aliyuncs.com"]
- 重启
containerd
:
sudo systemctl restart containerd
常用命令
# 列出所有镜像
crictl img
# 查看镜像详情
crictl inspecti <image-id>
# 拉取镜像
crictl pull <image-name>
# 删除镜像
crictl rmi <image-id>
# 清理未使用的镜像
crictl rmi --prune
# 查看运行中的容器
crictl ps
# 查看所有容器
crictl ps -a
# 查看容器详细信息
crictl inspect <container-id>
# 在容器中执行命令
crictl exec -it <container-id> -- <command>
评论区