Skip to Content
Docker:入门与实践,第三版
book

Docker:入门与实践,第三版

by Sean P. Kane, Karl Matthias
May 2025
Intermediate to advanced
418 pages
5h 47m
Chinese
O'Reilly Media, Inc.
Content preview from Docker:入门与实践,第三版

第 12 章 不断扩大的格局

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

可用于与 Linux 容器交互的工具在不断发展,尤其是 Kubernetes 多年来得到了广泛采用。

在本章中,我们将快速浏览一些受 Docker 启发但通常专注于改进特定用例的工具。这并不是一份全面的清单,而只是为了让你了解一些可供探索的类别和选项。

客户工具

在本节中,我们将介绍三种命令行工具:nerdctlpodmanbuildah 。对于熟悉 Docker 及其常见工作流程的人来说,所有这些工具可能都很有用。

书呆子

虽然 crictl1在许多基于containerd- 的环境中默认安装了 ,但nerdctl 是一个易于使用的兼容 Docker 的 CLIcontainerd ,值得一试。这意味着nerdctl 可以为使用 Docker 但需要支持不运行 Docker 守护进程的containerd 系统的人员和脚本提供非常简单的迁移路径。

举个简单的例子,如果你用kind 启动一个小型 Kubernetes 集群(我们在"Kind"一文中讨论过),你最终会得到一个基于containerd 的 Kubernetes 集群,它与docker CLI 并不直接兼容:

$ kind create cluster --name nerdctl
Creating cluster "nerdctl" …


$ docker container exec -ti nerdctl-control-plane /bin/bash

现在您应该在kind/Kubernetes 容器内了。

备注

在接下来的curl 命令中,您必须确保为您的系统架构下载了正确的版本。您需要将${ARCH} 替换为amd64arm64 ,具体取决于您的系统。此外,请尝试下载 nerdctl最新版本

编辑以下curl 命令并将其重新组合为一行后,就可以下载并解压nerdctl 客户端,然后尝试使用它执行一些命令:

root@nerdctl-control-plane:/# curl -s -L \
  "https://github.com/containerd/nerdctl/releases/download/v0.23.0/\
nerdctl-0.23.0-linux-${ARCH}.tar.gz" -o /tmp/nerdctl.tar.gz

root@nerdctl-control-plane:/# tar -C /usr/local/bin -xzf /tmp/nerdctl.tar.gz

root@nerdctl-control-plane:/# nerdctl namespace list

NAME      CONTAINERS    IMAGES    VOLUMES    LABELS
k8s.io    18            24        0

root@nerdctl-control-plane:/# nerdctl --namespace k8s.io container list

CONTAINER ID IMAGE                                  … NAMES
07ae69902d11 registry.k8s.io/pause:3.7              … k8s://kube-system/core…
0b241db0485f registry.k8s.io/coredns/coredns:v1.9.3 … k8s://kube-system/core…


root@nerdctl-control-plane:/# ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar
超越Vibe编程

超越Vibe编程

Addy Osmani
写给系统管理员的Python脚本编程指南

写给系统管理员的Python脚本编程指南

Posts & Telecom Press, Ganesh Sanjiv Naik

Publisher Resources

ISBN: 9798341656826