Files
Kubernetes/Containerd/Docs/Ctr基础命令.md
offends b44594def6
All checks were successful
continuous-integration/drone Build is passing
修改和新增
2025-12-23 01:53:01 +08:00

44 lines
1.6 KiB
Markdown

> 本文作者:丁辉
# Ctr命令使用
- 查看镜像
```bash
ctr -n k8s.io images ls
```
- 更改镜像 TAG
```bash
ctr -n k8s.io image tag nginx:v1 nginx:v2
```
- 拉取镜像
```bash
ctr -n k8s.io images pull docker.io/library/nginx:latest
```
**更多参数**
```bash
ctr --debug=true i pull --hosts-dir=/etc/containerd/certs.d docker.io/library/nginx:latest
```
| 参数部分 | 说明 | 详细解释 |
| :-------------------------------------: | :--: | :----------------------------------------------------------: |
| **--debug=true** | | - 启用详细日志输出 - 显示执行过程中的详细信息 - 便于故障排查 |
| **i** | | `images` 的缩写,表示进行镜像相关操作 |
| **pull** | | 拉取(下载)镜像到本地 |
| **--hosts-dir=/etc/containerd/certs.d** | | - 指定证书和注册表配置目录 - 用于配置私有注册表或镜像仓库的认证信息 - 可以覆盖默认的 registry 配置 |
| -k | | 忽略 TLS 验证过程中的证书错误 |
| --plain-http=true | | 此选项指明在拉取镜像时使用未加密的 HTTP 协议,而不是加密的 HTTPS |
- 推送镜像
```bash
ctr -n k8s.io image push -u <账户>:<密码> docker.io/library/nginx:latest
```