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:入门与实践,第三版

第 3 章 安装 Docker 安装 Docker

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

现在我们已经到了 希望你大致了解 Docker 是什么、不是什么的时候了,是时候进行一些实际操作了。让我们来安装 Docker,以便使用它。安装 Docker 所需的步骤因您用于开发的平台和用于在生产中托管应用程序的 Linux 发行版而异。

在本章中,我们将讨论在大多数现代桌面操作系统上建立一个完全可用的 Docker 开发环境所需的步骤。首先,我们将在本地开发平台上安装 Docker 客户端,然后让 Docker 服务器在 Linux 上运行。最后,我们将对安装进行测试,以确保其按预期运行。

虽然 Docker 客户端可以在 Windows 和 macOS 上运行,以控制 Docker 服务器,但 Linux 容器只能在 Linux 系统上构建和启动。因此,非 Linux 系统将需要一个虚拟机或远程服务器来托管基于 Linux 的 Docker 服务器。本章后面将讨论的 Docker Community Edition、Docker Desktop 和 Vagrant 都提供了一些方法来解决这个问题。也可以在 Windows 系统上原生运行 Windows 容器,我们将在"Windows 容器 "中专门讨论这个问题,但本书的大部分重点将放在 Linux 容器上。

备注

Docker 生态系统变化非常快,因为该技术不断发展,变得更加强大,能解决更广泛的问题。本书和其他地方讨论的某些功能可能会被弃用。要查看哪些功能已被标记为过时并最终被移除,请参阅文档

提示

在本书的大部分代码示例中,我们假设您使用的是 传统的 Unix shell。您可以使用 PowerShell,但要注意有些命令需要调整才能在该环境中运行。

如果您所处的环境 要求您使用代理,请确保为 Docker 正确配置了代理。

Docker 客户端

Docker 客户端原生支持 64 位版本的 Linux、Windows 和 macOS。

大多数流行的 Linux 发行版 都可以追溯到 Debian 或 Red Hat。Debian 系统利用 deb 软件包格式和高级软件包工具 (apt) 来安装大多数预打包软件。另一方面,Red Hat 系统依靠 RPM 软件包管理器 (rpm) 文件和Yellowdog Updater、 Modified (yum) 或Dandifiedyum (dnf) 来安装类似的软件包。Alpine Linux 通常用于要求 Linux 占用空间非常小的环境,它依靠Alpine Package Keeper (apk) 来管理软件包。

在 macOS 和 Microsoft Windows 上, 原生 GUI 安装程序提供了安装和维护预打包软件的最简单方法。MacOS 的 HomebrewWindows 的 Chocolatey也是技术用户非常喜欢的选择。

警告

我们将在本节讨论安装 Docker 的几种方法。请确保选择列表中最符合您需求的第一种方法。如果不熟悉如何正确切换,安装多个 Docker 可能会造成问题。

请选择其中一种:Docker 桌面、Docker 社区版、操作系统软件包管理器或 Vagrant。

您可以随时在 Docker 网站上找到最新的 安装文档

Linux

强烈建议您在首选 Linux 发行版的现代版本上运行 Docker。在一些旧版本上运行 Docker ...

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