根據(jù)過去幾年發(fā)生的重大變化,本書對示例和內(nèi)容做了全面修訂。本書作者新增了一章,是關(guān)于討論Docker Compose的,此外還深入探討了Docker Swarm模式,介紹了Kubernetes和AWS Fargate,并給出了優(yōu)化Docker映像的方法。本書的主要內(nèi)容有:學(xué)習(xí)如何使用Docker簡化依賴管理和應(yīng)用的部署流程。著手使用Docke映像、容器和命令行工具。使用實(shí)用的技術(shù)在生產(chǎn)環(huán)境中部署和測試Docker容器。理解容器的組成和內(nèi)部機(jī)理,便于調(diào)試。在數(shù)據(jù)中心或云環(huán)境中大規(guī)模部署容器。探討一些Docker高級話題,包括部署工具、網(wǎng)絡(luò)、編排、安全和配置。
Sean P. Kane是New Relic公司的首席網(wǎng)站可靠性工程師,長期從事生產(chǎn)運(yùn)維,有很多不同的頭銜,在很多行業(yè)中工作過。Karl Matthias是InVision公司的云平臺服務(wù)經(jīng)理,他做過開發(fā)者、分布式系統(tǒng)架構(gòu)師、系統(tǒng)管理員和網(wǎng)絡(luò)工程師,在初創(chuàng)公司和財富500強(qiáng)大企業(yè)都能見到他的身影。
序 ..................................................................................1
前言 ...............................................................................3
第1 章 引言 ................................................................. 11
1.1 Docker 帶來的希望 .......................................................................................... 11
1.2 Docker 不是什么..............................................................................................15
1.3 重要的術(shù)語 ......................................................................................................17
1.4 小結(jié) .................................................................................................................17
第2 章 Docker 概覽 ...................................................... 18
2.1 簡化流程 ..........................................................................................................18
2.2 廣泛支持和采用 ..............................................................................................21
2.3 架構(gòu) .................................................................................................................23
2.4 充分理解Docker..............................................................................................29
2.5 Docker 式工作流程 ..........................................................................................33
2.6 小結(jié) .................................................................................................................40
第3 章 安裝Docker ...................................................... 41
3.1 安裝Docker 客戶端 .........................................................................................42
3.2 安裝Docker 服務(wù)器 .........................................................................................46
3.3 測試安裝Docker..............................................................................................56
3.4 探索Docker 服務(wù)器 .........................................................................................57
3.5 小結(jié) .................................................................................................................59
第4 章 使用Docker 映像 .............................................. 61
4.1 剖析Dockerfile 文件 .......................................................................................62
4.2 構(gòu)建映像 ..........................................................................................................65
4.3 診斷構(gòu)建問題 ..................................................................................................68
4.4 運(yùn)行映像 ..........................................................................................................71
4.5 定制基礎(chǔ)映像 ..................................................................................................73
4.6 存儲映像 ..........................................................................................................73
4.7 高級構(gòu)建技術(shù) ..................................................................................................84
4.8 小結(jié) .................................................................................................................98
第5 章 使用Docker 容器 .............................................. 99
5.1 容器是什么? ..................................................................................................99
5.2 創(chuàng)建容器 ........................................................................................................102
5.3 啟動容器 ........................................................................................................ 119
5.4 自動重啟容器 ................................................................................................120
5.5 停止容器 ........................................................................................................121
5.6 終止容器 ........................................................................................................122
5.7 暫停和恢復(fù)容器 ............................................................................................123
5.8 清理容器和映像 ............................................................................................124
5.9 Windows 容器 ................................................................................................127
5.10 小結(jié) .............................................................................................................129
第6 章 探索Docker 的其他功能 .................................. 130
6.1 打印Docker 的版本號 ...................................................................................131
6.2 服務(wù)器信息 ....................................................................................................132
6.3 下載映像更新 ................................................................................................133
6.4 審查容器 ........................................................................................................134
6.5 在shell 中探索...............................................................................................136
6.6 返回結(jié)果 ........................................................................................................137
6.7 進(jìn)入運(yùn)行中的容器 .........................................................................................139
6.8 處理日志 ........................................................................................................145
6.9 監(jiān)控Docker ...................................................................................................151
6.10 Prometheus 監(jiān)控系統(tǒng) ...................................................................................164
6.11 繼續(xù)探索 ......................................................................................................168
6.12 小結(jié) .............................................................................................................168
第7 章 調(diào)試容器 ......................................................... 169
7.1 列出進(jìn)程 ........................................................................................................170
7.2 審查進(jìn)程 ........................................................................................................174
7.3 管理進(jìn)程 ........................................................................................................175
7.4 審查網(wǎng)絡(luò) ........................................................................................................178
7.5 查看映像歷史 ................................................................................................181
7.6 審查容器 ........................................................................................................182
7.7 審查文件系統(tǒng) ................................................................................................183
7.8 小結(jié) ...............................................................................................................184
第8 章 探索Docker Compose .................................... 185
8.1 配置Docker Compose ....................................................................................186
8.2 啟動服務(wù) ........................................................................................................193
8.3 探索RocketChat ............................................................................................195
8.4 Docker Compose 命令 ....................................................................................205
8.5 小結(jié) ...............................................................................................................207
第9 章 在生產(chǎn)環(huán)境中部署容器 .................................... 208
9.1 部署到生產(chǎn)環(huán)境 ............................................................................................208
9.2 Docker 在生產(chǎn)環(huán)境中扮演的角色 .................................................................209
9.3 Docker 和DevOps 流水作業(yè) .........................................................................219
9.4 小結(jié) ...............................................................................................................224
第10 章 大規(guī)模使用Docker ........................................ 225
10.1 Centurion .....................................................................................................226
10.2 Docker Swarm 模式 .....................................................................................232
10.3 Amazon ECS 和Fargate ...............................................................................242
10.4 Kubernetes ...................................................................................................256
10.5 小結(jié) .............................................................................................................276
第11 章 高級主題 ....................................................... 278
11.1 容器詳解 ......................................................................................................278
11.2 安全性 ..........................................................................................................288
11.3 高級配置 ......................................................................................................302
11.4 存儲后端 ......................................................................................................309
11.5 Docker 的結(jié)構(gòu) .............................................................................................313
11.6 替換運(yùn)行時 ..................................................................................................317
11.7 小結(jié) .............................................................................................................323
第12 章 容器平臺設(shè)計 ................................................ 324
12.1 應(yīng)用的十二要素 ...........................................................................................325
12.2 響應(yīng)式宣言 ..................................................................................................334
12.3 小結(jié) .............................................................................................................335
第13 章 總結(jié) ............................................................. 336
13.1 Docker 解決的問題 ......................................................................................336
13.2 Docker 式工作流程 ......................................................................................337
13.3 簡化用于部署的構(gòu)建產(chǎn)物 ............................................................................338
13.4 使用最佳方式存儲和獲取映像 ....................................................................338
13.5 回報 .............................................................................................................339
13.6 結(jié)語 .............................................................................................................340