dmz社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1586|回复: 16

[服务器] TL Docker开发指南(pdf)

[复制链接]
  • TA的每日心情
    奋斗
    2023-5-5 00:22
  • 签到天数: 32 天

    [LV.5]常住居民I

    307

    主题

    280

    帖子

    1284

    积分

    荣誉会员

    积分
    1284

    发表于 2022-7-25 02:00:05 | 显示全部楼层 |阅读模式

    本站资源全部免费,回复即可查看下载地址!

    您需要 登录 才可以下载或查看,没有帐号?立即注册

    x
    1.png

    前言 ..........................................................................................................................................................xi
    第一部分 背景与基础
    第 1 章 何谓容器,为何需要它 .....................................................................................................3
    1.1 容器与虚拟机的比较 .................................................................................................................4
    1.2 Docker 与容器 ............................................................................................................................5
    1.3 Docker 的历史 ............................................................................................................................7
    1.4 插件与基础设施 .........................................................................................................................8
    1.5 64 位 Linux .................................................................................................................................9
    第 2 章 安装 .......................................................................................................................................10
    2.1 在 Linux 上安装 Docker ...........................................................................................................10
    2.1.1 将 SELinux 置于宽容模式下运行 ..............................................................................11
    2.1.2 不使用 sudo 命令执行 Docker ....................................................................................11
    2.2 在 Mac OS 及 Windows 上安装 Docker ..................................................................................12
    2.3 快速确认 ...................................................................................................................................13
    第 3 章 迈出第一步 .........................................................................................................................15
    3.1 运行第一个镜像 .......................................................................................................................15
    3.2 基本命令 ...................................................................................................................................16
    3.3 通过 Dockerfile 创建镜像 ........................................................................................................20
    3.4 使用寄存服务 ...........................................................................................................................22
    vi | 目录
    3.5 使用 Redis 官方镜像 ................................................................................................................24
    3.6 总结 ...........................................................................................................................................27
    第 4 章 Docker 基本概念 ...............................................................................................................28
    4.1 Docker 系统架构 ......................................................................................................................28
    4.1.1 底层技术 ......................................................................................................................29
    4.1.2 周边技术 ......................................................................................................................30
    4.1.3 Docker 托管 ..................................................................................................................31
    4.2 镜像是如何生成的 ...................................................................................................................32
    4.2.1 构建环境的上下文 ......................................................................................................32
    4.2.2 镜像层 ..........................................................................................................................33
    4.2.3 缓存 ..............................................................................................................................35
    4.2.4 基础镜像 ......................................................................................................................35
    4.2.5 Dockerfile 指令.............................................................................................................37
    4.3 使容器与世界相连 ...................................................................................................................39
    4.4 容器互联 ...................................................................................................................................40
    4.5 利用数据卷和数据容器管理数据 ...........................................................................................41
    4.5.1 共享数据 ......................................................................................................................43
    4.5.2 数据容器 ......................................................................................................................44
    4.6 Docker 常用命令 ......................................................................................................................45
    4.6.1 run 命令 ........................................................................................................................46
    4.6.2 容器管理 ......................................................................................................................48
    4.6.3 Docker 信息 ..................................................................................................................50
    4.6.4 容器信息 ......................................................................................................................50
    4.6.5 镜像管理 ......................................................................................................................52
    4.6.6 使用寄存服务器 ..........................................................................................................54
    4.7 总结 ...........................................................................................................................................55
    第二部分 Docker 与软件生命周期
    第 5 章 在开发中应用 Docker ......................................................................................................59
    5.1 说声“Hello World!” ...............................................................................................................59
    5.2 通过 Compose 实现自动化 ......................................................................................................67
    5.3 总结 ...........................................................................................................................................69
    第 6 章 创建一个简单的 Web 应用 ............................................................................................71
    6.1 创建一个基本网页 ...................................................................................................................72
    目录 | vii
    6.2 利用现有镜像 ...........................................................................................................................73
    6.3 实现缓存功能 ...........................................................................................................................78
    6.4 微服务 .......................................................................................................................................81
    6.5 总结 ...........................................................................................................................................81
    第 7 章 镜像分发 ..............................................................................................................................82
    7.1 镜像及镜像库的命名方式 .......................................................................................................82
    7.2 Docker Hub ...............................................................................................................................83
    7.3 自动构建 ...................................................................................................................................85
    7.4 私有分发 ...................................................................................................................................86
    7.4.1 运行自己的寄存服务 ..................................................................................................86
    7.4.2 商业寄存服务 ..............................................................................................................92
    7.5 缩减镜像大小 ...........................................................................................................................92
    7.6 镜像出处 ...................................................................................................................................94
    7.7 总结 ...........................................................................................................................................94
    第 8 章 Docker 持续集成与测试 .................................................................................................95
    8.1 为 identidock 添加单元测试 ....................................................................................................95
    8.2 创建 Jenkins 容器 ...................................................................................................................100
    8.3 推送镜像 .................................................................................................................................106
    8.3.1 给镜像正确的标签 ....................................................................................................106
    8.3.2 准生产及生产环境 ....................................................................................................108
    8.3.3 镜像数量激增的问题 ................................................................................................108
    8.3.4 使用 Docker 部署 Jenkins slaves ...............................................................................109
    8.4 备份 Jenkins 数据 ...................................................................................................................109
    8.5 持续集成的托管解决方案 .....................................................................................................109
    8.6 测试与微服务 .........................................................................................................................110
    8.7 总结 .........................................................................................................................................111
    第 9 章 部署容器 ............................................................................................................................113
    9.1 通过 Docker Machine 配置资源 ............................................................................................114
    9.2 使用代理 .................................................................................................................................117
    9.3 执行选项 .................................................................................................................................122
    9.3.1 shell 脚本 ....................................................................................................................122
    9.3.2 使用进程管理器(或用 systemd 控制所有进程) ..................................................124
    9.3.3 使用配置管理工具 ....................................................................................................127
    9.4 主机配置 .................................................................................................................................130
    9.4.1 选择操作系统 ............................................................................................................130
    viii | 目录
    9.4.2 选择存储驱动程序 ....................................................................................................130
    9.5 专门的托管方案 .....................................................................................................................132
    9.5.1 Triton ...........................................................................................................................132
    9.5.2 谷歌容器引擎 ............................................................................................................134
    9.5.3 亚马逊 EC2 容器服务 ...............................................................................................135
    9.5.4 Giant Swarm ...............................................................................................................136
    9.6 持久性数据和生产环境容器 .................................................................................................138
    9.7 分享秘密信息 .........................................................................................................................139
    9.7.1 在镜像中保存秘密信息 ............................................................................................139
    9.7.2 通过环境变量传递密钥 ............................................................................................139
    9.7.3 通过数据卷传递密钥 ................................................................................................140
    9.7.4 使用键值存储 ............................................................................................................140
    9.8 网络连接 .................................................................................................................................141
    9.9 生产环境的寄存服务 .............................................................................................................141
    9.10 持续部署 / 交付 ....................................................................................................................141
    9.11 总结 .......................................................................................................................................142
    第 10 章 日志记录和监控 ............................................................................................................143
    10.1 日志记录 ...............................................................................................................................144
    10.1.1 Docker 默认的日志记录 ........................................................................................144
    10.1.2 日志汇总 .................................................................................................................145
    10.1.3 使用 ELK 进行日志记录 .......................................................................................146
    10.1.4 通过 syslog 实现日志管理 .....................................................................................155
    10.1.5 从文件抓取日志 .....................................................................................................160
    10.2 监控和警报 ...........................................................................................................................161
    10.2.1 使用 Docker 工具进行监测 ...................................................................................161
    10.2.2 cAdvisor ..................................................................................................................162
    10.2.3 集群解决方案 .........................................................................................................163
    10.3 商用的监听及日志记录解决方案 .......................................................................................166
    10.4 总结 .......................................................................................................................................166
    第三部分 工具和技术
    第 11 章 联网和服务发现 ............................................................................................................169
    11.1 大使容器 ...............................................................................................................................170
    11.2 服务发现 ...............................................................................................................................173
    11.2.1 etcd ..........................................................................................................................173
    目录 | ix
    11.2.2 SkyDNS ...................................................................................................................177
    11.2.3 Consul ......................................................................................................................181
    11.2.4 服务注册 .................................................................................................................185
    11.2.5 其他解决方案 .........................................................................................................186
    11.3 联网选项 ...............................................................................................................................187
    11.3.1 网桥模式 .................................................................................................................187
    11.3.2 主机模式 .................................................................................................................188
    11.3.3 容器模式 .................................................................................................................188
    11.3.4 未联网模式 ............................................................................................................188
    11.4 全新的 Docker 联网功能 .....................................................................................................188
    11.5 网络解决方案 .......................................................................................................................190
    11.5.1 Overlay ....................................................................................................................191
    11.5.2 Weave ......................................................................................................................193
    11.5.3 Flannel .....................................................................................................................196
    11.5.4 Calico 项目 ..............................................................................................................201
    11.6 总结 .......................................................................................................................................205
    第 12 章 编排Ƚ集群和管理 .......................................................................................................207
    12.1 集群和编排工具 ...................................................................................................................208
    12.1.1 Swarm ......................................................................................................................208
    12.1.2 fleet ..........................................................................................................................214
    12.1.3 Kubernetes ...............................................................................................................219
    12.1.4 Mesos 和 Marathon .................................................................................................226
    12.2 容器管理平台 .......................................................................................................................235
    12.2.1 Rancher ....................................................................................................................236
    12.2.2 Clocker ....................................................................................................................237
    12.2.3 Tutum ......................................................................................................................238
    12.3 总结 .......................................................................................................................................239
    第 13 章 容器安全与限制容器 ...................................................................................................241
    13.1 需要考虑的事项 ...................................................................................................................242
    13.2 纵深防御 ...............................................................................................................................244
    13.3 如何保护 identidock .............................................................................................................245
    13.4 以主机隔离容器 ...................................................................................................................246
    13.5 进行更新 ...............................................................................................................................246
    13.6 镜像出处 ...............................................................................................................................249
    13.6.1 Docker 摘要 ............................................................................................................250
    13.6.2 Docker 的内容信任机制 ........................................................................................250
    x | 目录
    13.6.3 可复制及可信任的 Dockerfile ...............................................................................254
    13.7 安全建议 ...............................................................................................................................256
    13.7.1 设置用户 .................................................................................................................256
    13.7.2 限制容器联网 .........................................................................................................257
    13.7.3 删除 setuid 和 setgid 的二进制文件 ......................................................................258
    13.7.4 限制内存使用 .........................................................................................................259
    13.7.5 限制 CPU 使用 .......................................................................................................260
    13.7.6 限制重新启动 .........................................................................................................261
    13.7.7 限制文件系统 .........................................................................................................261
    13.7.8 限制内核能力 .........................................................................................................262
    13.7.9 应用资源限制 .........................................................................................................263
    13.8 运行加固内核 .......................................................................................................................264
    13.9 Linux 安全模块 ....................................................................................................................265
    13.9.1 SELinux ...................................................................................................................265
    13.9.2 AppArmor ...............................................................................................................268
    13.10 审核 .....................................................................................................................................268
    13.11 事件响应 .............................................................................................................................269
    13.12 未来特性 .............................................................................................................................269
    13.13 总结 .....................................................................................................................................270
    作者简介 ..............................................................................................................................................271
    关于封面 ..............................................................................................................................................271


    游客,如果您要查看本帖隐藏内容请回复

    温馨提示:
    1、本站所有内容均为互联网收集或网友分享或网络购买,本站不破解、不翻录任何视频!
    2、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意!
    3、本站资源仅供本站会员学习参考,不得传播及用于其他用途,学习完后请在24小时内自行删除.
    4、本站资源质量虽均经精心审查,但也难保万无一失,若发现资源有问题影响学习请一定及时点此进行问题反馈,我们会第一时间改正!
    5、若发现链接失效了请联系管理员,管理员会在2小时内修复
    6、如果有任何疑问,请加客服QQ:1300822626 2小时内回复你!
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    昨天 09:46
  • 签到天数: 1298 天

    [LV.10]以坛为家III

    1

    主题

    4725

    帖子

    1万

    积分

    超凡入圣

    Rank: 10Rank: 10Rank: 10

    积分
    13033

    发表于 2022-7-25 08:35:01 | 显示全部楼层
    啥也不说了,感谢楼主分享哇!
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    6 天前
  • 签到天数: 142 天

    [LV.7]常住居民III

    2

    主题

    529

    帖子

    1473

    积分

    一代宗师

    Rank: 7Rank: 7Rank: 7

    积分
    1473

    发表于 2022-7-25 09:18:57 | 显示全部楼层
    啥也不说了,感谢楼主分享哇!
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    擦汗
    2022-10-28 09:42
  • 签到天数: 60 天

    [LV.6]常住居民II

    0

    主题

    214

    帖子

    567

    积分

    技冠群雄

    Rank: 6Rank: 6

    积分
    567

    发表于 2022-7-25 10:47:19 | 显示全部楼层
    么有分,谁能送我点积分啊::>_<::
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    昨天 23:29
  • 签到天数: 699 天

    [LV.9]以坛为家II

    0

    主题

    821

    帖子

    3615

    积分

    傲视群雄

    Rank: 8Rank: 8

    积分
    3615

    发表于 2022-7-25 13:22:14 | 显示全部楼层
    确实是难得好帖啊,顶先
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    3 天前
  • 签到天数: 213 天

    [LV.7]常住居民III

    0

    主题

    378

    帖子

    1416

    积分

    一代宗师

    Rank: 7Rank: 7Rank: 7

    积分
    1416

    发表于 2022-7-25 22:58:40 | 显示全部楼层
    kkkkkkkkkkkkkkkkkkk
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    昨天 12:38
  • 签到天数: 958 天

    [LV.10]以坛为家III

    4

    主题

    2341

    帖子

    7845

    积分

    深不可测

    Rank: 9Rank: 9Rank: 9

    积分
    7845

    发表于 2022-7-25 23:24:27 | 显示全部楼层
    啥也不说了,感谢楼主分享哇!
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    慵懒
    昨天 14:43
  • 签到天数: 893 天

    [LV.10]以坛为家III

    1

    主题

    4717

    帖子

    1万

    积分

    终身会员[A]

    Rank: 7Rank: 7Rank: 7

    积分
    11844

    发表于 2022-7-26 11:26:56 | 显示全部楼层
    啥也不说了,感谢楼主分享哇!
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2024-4-26 00:47
  • 签到天数: 343 天

    [LV.8]以坛为家I

    1

    主题

    701

    帖子

    2256

    积分

    终身会员[B]

    积分
    2256

    发表于 2022-8-4 13:30:19 | 显示全部楼层
    啥也不说了,感谢楼主分享哇!
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    5 天前
  • 签到天数: 479 天

    [LV.9]以坛为家II

    1

    主题

    1150

    帖子

    3849

    积分

    傲视群雄

    Rank: 8Rank: 8

    积分
    3849

    发表于 2022-8-30 18:51:59 | 显示全部楼层
    啥也不说了,感谢楼主分享哇!
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|小黑屋|本站代理|dmz社区

    GMT+8, 2024-12-23 12:53 , Processed in 0.112013 second(s), 41 queries .

    Powered by Discuz! X3.4 Licensed

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表