Docker Source Code Analysis cover

Docker Source Code Analysis

Rating 3.3
Word count
282K words
Chapters
20
Series
Container Technology Series
ISBN
9787111510727

Tags

Summary

Docker Source Code Analysis is a technical monograph by Sun Hongliang on the implementation principles of Docker, published by China Machine Press in 2015 as part of the "Container Technology Series." Based on the Docker 1.2.0 source code, the author uses flowcharts and code snippets to break down Docker's architecture and key modules layer by layer. The book is divided into three parts. Part One, Chapter 1, presents the overall Docker architecture from a macro perspective, introducing the responsibilities and implementations of Docker Client, Docker Daemon, Docker Registry, Graph, Driver, libcontainer, and Docker Container, and linking the overall process through two runtime examples: docker pull and docker run. Part Two, Chapters 2 to 14, is the main body of the book. Chapters 2 to 8 outline the skeleton of the Docker software, covering Client creation and command execution, Daemon startup and the NewDaemon implementation, Server creation, and Daemon networking and container networking (bridge, host, other container, none, and other modes). Chapters 9 to 11 focus on image technology, explaining image downloading, image storage (graphdriver storage drivers), and the implementation of docker build. Chapters 12 to 14 analyze the complete process of container creation, including container creation, dockerinit startup, and the role of libcontainer. Part Three, Chapters 15 to 17, introduces the architecture and implementation of Swarm, Machine, and Compose, collectively known as the "three carriages" of the Docker ecosystem, supplementing Docker's capabilities in cross-host clustering and deployment. The book positions itself as a "technical popularization reader," aiming to let both users and developers understand how containers actually run through the source code.

Editor's review

“会用Docker”和“懂Docker”之间,隔着一层源代码。这本书正适合希望补上这一层的人:它不介绍命令速查,也不演示应用案例,而是把Docker 1.2.0的源码当作地图,按“先看骨架、再看器官、最后看生态”的顺序一路读下去。第一部分的总体架构图是全书地图,建议对照阅读;第2至8章从Client发出一条命令开始,跟到Daemon启动、Server接单、网络建立,把看似复杂的流程串成一条线;第9至14章的镜像与容器部分最能体现Docker“分层”与“隔离”的本质,graphdriver、dockerinit、libcontainer 这些平时只在报错信息里出现的名字,都能在这里找到具体位置;最后三章则将视野从单机引向Swarm、Machine、Compose组成的集群与部署工具链。作者用大量流程图和代码片段替代抽象叙述,章节间耦合度低,可以挑重点读,也适合通读。需要注意的是,书成于2015年,Docker版本迭代极快,源码细节与今天的实现已有差异,读它的价值在于理解设计思路与机制脉络,而非查找现成API。

Who it's for

A good fit for

  • 有Docker日常使用经验、想弄清底层实现原理的后端与运维工程师
  • 正在搭建容器云平台、需要理解镜像与网络机制的架构师
  • 熟悉Go语言,想通过真实项目源码学习工程结构的中高级开发者
  • 计算机专业高年级学生与研究生,用于理解Linux命名空间、Cgroups等虚拟化基础

Not a good fit for

  • 完全没接触过Docker命令与概念的零基础读者,宜先读入门书
  • 只想找Docker命令速查、最佳实践或面试题库的读者
  • 需要与当前Docker版本完全对应的API与源码细节的开发者,需另行查阅官方文档

Reading tips

  1. 先精读第1章架构图与两个运行案例(docker pull、docker run),建立全局坐标再进细节。
  2. 按主题分块读:网络(第6~7章)可单独成组;先读第9~11章镜像部分,再读容器部分,会更容易理解分层机制。
  3. 读代码时打开对应版本(Docker 1.2.0)的源码仓库,边看边对照,比只看书中片段收效更大。
  4. 在书上标注与当前版本差异较大的地方,善用官方文档补充,把重点放在设计思想而非具体函数名上。

About the publisher

China Machine Press China · Founded in 1950

In addition to science and technology and professional publishing, the books in our catalog from China Machine Press also reflect a sustained focus on psychology, computing, management, finance and economics, and social sciences. In psychology, the catalog includes works by C. G. Jung and introductions to analytical psychology, as well as applied topics such as stress and health, and addiction and healing. In computing, it features Structure and Interpretation of Computer Programs (JavaScript Edition). Management and finance titles include Administrative Behavior (4th Edition), The Price of Inequality (Collector's Edition), and This Time Is Different: Eight Centuries of Financial Folly (Commemorative Edition). In the philosophy and history of science, there is The Worldview: The Third Edition. Relevant authors include C. G. Jung, William McGuire, Sonu Shamdasani, and Gabor Maté. Public information is limited; the above summarizes the publisher's profile based solely on the books in our catalog.

Contents

  1. Praise
  2. Foreword
  3. Preface
  4. Chapter 1 Docker Architecture
  5. Chapter 2 Docker Client Creation and Command Execution
  6. Chapter 3 Starting the Docker Daemon
  7. Chapter 4 The NewDaemon Implementation in Docker Daemon
  8. Chapter 5 Creation of the Docker Server
  9. Chapter 6 Docker Daemon Networking
  10. Chapter 7 Docker Container Networking
  11. Chapter 8 Docker Images
  12. Chapter 9 Docker Image Downloading
  13. Chapter 10 Docker Image Storage
  14. Chapter 11 Implementation of docker build
  15. Chapter 12 Docker Container Creation
  16. Chapter 13 dockerinit Startup
  17. Chapter 14 Introduction to libcontainer
  18. Chapter 15 Swarm Architecture Design and Implementation
  19. Chapter 16 Machine Architecture Design and Implementation
  20. Chapter 17 Compose Architecture Design and Implementation

FAQ

这本书讲的是哪个版本的Docker源码?
据公开资料,全书基于Docker 1.2.0版本源码展开解析,成书于2015年。此后Docker架构变动较大(如Swarm模式整合、runc取代部分libcontainer职责等),阅读时应把它当作理解机制的参考,而非当前版本的权威实现文档。
没有读过Docker入门书能直接看这本吗?
不太建议。本书从源码层面切入,默认读者了解镜像、容器、仓库等基本概念并会使用常用命令。若完全没有基础,建议先读一本Docker入门书并动手跑通几个容器,再回来看这本书会顺畅很多。
书里为什么要讲Swarm、Machine和Compose?
当时Docker单机能力已经很强,但跨主机集群与部署能力需要生态工具补齐。作者把这三者称为Docker生态的“三驾马车”,分别对应集群编排、主机管理与多容器应用编排,用三章讲解其架构与实现思路。
这本书只有一百多页,内容会不会太浅?
不同渠道标注的页数不一致(有164页与247页两种说法),但页数少并不代表浅。全书以流程图和代码片段为主、文字精炼,信息密度较高;真正的消化程度取决于是否对照源码动手跟进。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

Top rated in the same category