wiki/运维/容器/Docker/docker和crictl和ctr命令区别.md
2025-01-02 10:46:09 +08:00

38 lines
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Docker和Containerd命令区别
categories:
- 小技巧
tags:
- k8s
date: 2023-03-27 13:24:33
---
# Dcoker和Containerd命令区别
| 命令 | docker | ctrcontainerd | crictlkubernetes |
| :----------------------: | :----------------: | :--------------------------: | :------------------: |
| 查看运行的容器 | docker ps | ctr task ls/ctr container ls | crictl ps |
| 查看镜像 | docker images | ctr image ls | crictl images |
| 查看容器日志 | docker logs | 无 | crictl logs |
| 查看容器数据信息 | docker inspect | ctr container info | crictl inspect |
| 查看容器资源 | docker stats | 无 | crictl stats |
| 启动/关闭已有的容器 | docker start/stop | ctr task start/kill | crictl start/stop |
| 运行一个新的容器 | docker run | ctr run | 无(最小单元为 pod |
| 打标签 | docker tag | ctr image tag | 无 |
| 创建一个新的容器 | docker create | ctr container create | crictl create |
| 导入镜像 | docker load | ctr image import | 无 |
| 导出镜像 | docker save | ctr image export | 无 |
| 删除容器 | docker rm | ctr container rm | crictl rm |
| 删除镜像 | docker rmi | ctr image rm | crictl rmi |
| 拉取镜像 | docker pull | ctr image pull | ctictl pull |
| 推送镜像 | docker push | ctr image push | 无 |
| 登录或在容器内部执行命令 | docker exec | 无 | crictl exec |
| 清空不用的容器 | docker image prune | 无 | crictl rmi --prune |
`crictl``ctr` 都是 Kubernetes 中用于管理容器运行时的命令行工具。
`crictl` 是一个 CLI 工具,用于与 CRI容器运行时接口兼容的容器运行时进行通信。它可以用来列出容器镜像、创建和删除容器等操作。
`ctr` 是 Docker 提供的一个 CLI 工具,用于与容器和镜像进行交互。它也可以用来在 Kubernetes 中管理容器,包括在 Kubernetes 中创建、删除和更新容器。
因此,`crictl``ctr` 的主要区别在于它们与不同的容器运行时进行通信,以及它们提供的功能集。如果您使用 CRI 兼容的容器运行时,建议使用 `crictl` 进行操作。如果您使用 Dockercontainerd 作为容器运行时,建议使用 `ctr` 进行操作。