Web site
For more books click to >> CiCi Island
download
Electronic version is only for preview and learning exchange use, please delete within 24 hours after downloading, support genuine edition, like to buy genuine books
- E-book download (Pipi Cloud Disk – click “Normal Download”)
- Purchase genuine
Cover page
The editors recommend
Docker tools for different developers! Comprehensive content: basic commands, advanced usage are all included, knowledge points are fully covered. Live learning and application: a large number of practical cases are displayed to guide the use and deepen understanding. Fresh knowledge: Follow up the evolution of Docker based on * documents and materials.
Content abstract
As the technology that has led the container virtualization space in recent years, Docker is on the rise. However, due to its appearance only a few years ago, the information about it, especially in Chinese, is still relatively scarce, leading to many developers in China feel strange to it. This book is based on the concept of preaching Docker, and shows the charm of Docker in all aspects from the basic concepts of Docker, conventional use methods, demonstration of operation practice, demonstration of improved and advanced usage, analysis of internal principles and underlying architecture and so on. From concept to practice, this book presents Docker to readers from different aspects with strong practicability. It can not only be used as an introductory textbook for learning Docker, but also as an instruction manual for Docker operation and practice, and even as a knowledge storehouse for improving and advancing. This book has a strong readability for people with different cognitive levels and knowledge reserves of Docker, as well as developers, testers or operation and maintenance personnel in the process of software development and deployment.
Author’s brief introduction
Changlong Xiong, senior architect, Web full stack developer, well-known blogger, author of Beaver Framework, initiator of open source group Funcuter, dedicated to the research and promotion of emerging technologies. He participated in the research of intelligent routing in his early years, and a number of research results influenced the development of home router. The Beaver framework, designed and implemented, has been used in the underlying programming architecture of tens of millions of systems. Funcuter open Source group, which aims to gather outstanding open source projects and developers in China, has several open source projects at present. In recent years, it has been committed to the research and promotion of cutting-edge technology, hoping to let more developers more easily contact, understand the latest scientific and technological achievements, and apply them to the development practice.
Orders to record
目 录
第一部分 基础篇
第1章 初识Docker 1
1.1 虚拟化 2
1.1.1 虚拟化技术 2
1.1.2 虚拟化的分类 4
1.2 容器技术与Docker 6
1.2.1 容器技术 6
1.2.2 Docker简介 8
1.2.3 改变世界的发明 10
1.3 Docker的安装 10
1.3.1 在Ubuntu中安装Docker 11
1.3.2 在CentOS中安装Docker 12
1.3.3 在Windows中安装Docker 13
1.3.4 在Mac OS中安装Docker 15
1.3.5 在其他系统中安装Docker 16
1.4 Docker的优势 17
1.4.1 革命性的虚拟化方案 17
1.4.2 高效的容器技术 18
1.4.3 社区的力量 19
1.5 Docker的应用场景 20
1.5.1 超短时间部署运行 20
1.5.2 节约迁移时间 21
1.6 本章小结 21
第2章 镜像与仓库 22
2.1 镜像的概念 22
2.1.1 联合文件系统 22
2.1.2 Docker中的镜像 23
2.1.3 镜像的分层结构 24
2.1.4 镜像的写时复制 25
2.2 使用和管理镜像 26
2.2.1 获取镜像 26
2.2.2 列出镜像 28
2.2.3 获得镜像的详细信息 28
2.2.4 删除镜像 31
2.2.5 镜像的迁移 32
2.3 Docker Hub 33
2.3.1 镜像仓库 33
2.3.2 Docker Hub 34
2.3.3 注册Docker Hub账号 35
2.3.4 搜索镜像 36
2.3.5 共享自动构建镜像 38
2.4 搭建私有仓库 40
2.4.1 镜像分发服务 40
2.4.2 Docker Registry HTTP API 41
2.4.3 部署私有仓库 42
2.5 本章小结 44
第3章 管理和使用容器 45
3.1 管理容器 45
3.1.1 创建容器 45
3.1.2 容器的启动过程 48
3.1.3 列出容器 49
3.1.4 容器的命名 51
3.1.5 启动和停止 52
3.1.6 暂停和恢复 53
3.1.7 重启容器 54
3.1.8 删除容器 55
3.2 连接到容器 55
3.2.1 查看进程信息 56
3.2.2 查看容器信息 56
3.2.3 容器日志 62
3.2.4 衔接到容器 63
3.2.5 在容器中执行命令 64
3.3 容器的保存与迁移 65
3.3.1 提交容器更改 65
3.3.2 容器的导入/导出 68
3.4 本章小结 70
第4章 数据卷与网络 71
4.1 数据卷 71
4.1.1 关于数据卷 71
4.1.2 数据卷的特点 72
4.1.3 创建数据卷 73
4.1.4 挂载数据卷 74
4.1.5 删除数据卷 76
4.2 数据卷容器 77
4.2.1 关于数据卷容器 77
4.2.2 创建数据卷容器 78
4.2.3 连接数据卷容器 79
4.2.4 数据卷的迁移 80
4.3 网络基础 82
4.3.1 网络简介 82
4.3.2 查看网络配置 83
4.4 网络访问 85
4.4.1 宿主机端口映射 85
4.4.2 容器连接 87
4.5 本章小结 90
第5章 制作镜像 91
5.1 了解Dockerfile 91
5.1.1 Dockerfile简介 92
5.1.2 使用Dockerfile创建镜像 94
5.2 基础指令 96
5.2.1 FROM 97
5.2.2 MAINTAINER 97
5.3 控制指令 97
5.3.1 RUN 97
5.3.2 WORKDIR 99
5.3.3 ONBUILD 99
5.4 引入指令 100
5.4.1 ADD 100
5.4.2 COPY 102
5.5 执行指令 102
5.5.1 CMD 102
5.5.2 ENTRYPOINT 104
5.6 配置指令 107
5.6.1 EXPOSE 108
5.6.2 ENV 108
5.6.3 LABEL 109
5.6.4 USER 110
5.6.5 ARG 111
5.6.6 STOPSIGNAL 112
5.6.7 SHELL 113
5.7 特殊用法 113
5.7.1 环境变量 113
5.7.2 指令解析 114
5.7.3 忽略文件 116
5.8 本章小结 117
第二部分 实践篇
第6章 SSH服务 118
6.1 在Docker中使用SSH 118
6.1.1 SSH简介 119
6.1.2 SSH使用方法简介 119
6.1.3 数据卷管理容器 121
6.1.4 使用SSH服务容器 122
6.2 构建SSH服务镜像 124
6.2.1 构建方式比较 124
6.2.2 通过提交构建 125
6.2.3 使用Dockerfile构建 127
6.3 本章小结 131
第7章 Web服务器 132
7.1 Web服务简介 132
7.1.1 万维网与网站 132
7.1.2 Web服务 133
7.1.3 Web服务程序 135
7.2 Apache 135
7.2.1 Apache简介 135
7.2.2 安装Apache 136
7.2.3 构建Apache镜像 139
7.2.4 测试Apache容器 142
7.3 Nginx 143
7.3.1 关于Nginx 143
7.3.2 安装Nginx 144
7.3.3 构建Nginx镜像 146
7.3.4 测试Nginx镜像 148
7.4 Tomcat 148
7.4.1 Tomcat简介 149
7.4.2 安装Tomcat 149
7.4.3 构建Tomcat镜像 152
7.5 本章小结 153
第8章 数据库程序 155
8.1 MySQL 155
8.1.1 MySQL简介 156
8.1.2 安装MySQL 156
8.1.3 构建MySQL镜像 162
8.1.4 测试MySQL容器 164
8.2 MongoDB 166
8.2.1 MongoDB简介 166
8.2.2 安装MongoDB 167
8.2.3 构建MongoDB镜像 171
8.2.4 测试MongoDB容器 173
8.3 本章小结 176
第9章 缓存工具 177
9.1 Memcached 178
9.1.1 Memcached简介 178
9.1.2 安装Memcached 179
9.1.3 构建Memcached镜像 184
9.1.4 测试Memcached容器 186
9.2 Redis 188
9.2.1 Redis简介 188
9.2.2 安装Redis 188
9.2.3 构建Redis镜像 193
9.2.4 测试Redis容器 195
9.3 本章小结 196
第10章 动态处理程序 197
10.1 Java 197
10.1.1 Java简介 198
10.1.2 安装Java 198
10.1.3 构建Java镜像 204
10.1.4 测试Java容器 206
10.2 PHP 207
10.2.1 PHP简介 207
10.2.2 安装PHP 208
10.2.3 构建PHP镜像 214
10.2.4 测试PHP容器 216
10.3 Python 217
10.3.1 Python简介 217
10.3.2 安装Python 218
10.3.3 构建Python镜像 223
10.3.4 测试Python容器 224
10.4 Node.js 225
10.4.1 Node.js简介 225
10.4.2 安装Node.js 226
10.4.3 构建Node.js镜像 228
10.4.4 测试Node.js容器 230
10.5 本章小结 231
第11章 综合演练 232
11.1 演练目标 232
11.1.1 目标概述 232
11.1.2 代码编写 233
11.2 环境搭建 237
11.2.1 准备镜像 237
11.2.2 程序配置 239
11.3 项目运行 248
11.3.1 启动容器 248
11.3.2 测试项目 249
11.4 本章小结 253
第三部分 提高篇
第12章 网络进阶 254
12.1 网络实现 254
12.1.1 容器网络基础 255
12.1.2 网络模型 257
12.2 Docker中的网络 258
12.2.1 默认网络 258
12.2.2 自定义网络 261
12.2.3 容器与外部通信 262
12.2.4 容器间通信 264
12.3 网络实践 265
12.3.1 管理容器网络 265
12.3.2 容器连接网络 267
12.3.3 配置docker0网桥 269
12.3.4 自定义网桥 271
12.3.5 配置DNS 271
12.3.6 使用IPv6 273
12.4 本章小结 274
第13章 安全加固 275
13.1 深入理解Docker安全 275
13.1.1 命名空间隔离 276
13.1.2 资源控制组 277
13.1.3 内核能力机制 277
13.2 资源使用限制 278
13.2.1 通过控制组限制 278
13.2.2 通过ulimit限制 280
13.2.3 网络访问限制 280
13.3 校验与监控 281
13.3.1 镜像签名 281
13.3.2 运行状态监控 283
13.4 联级防护 284
13.4.1 组合虚拟化 284
13.4.2 文件系统安全 284
13.5 内核安全技术 285
13.5.1 Capability 286
13.5.2 SELinux 287
13.5.3 AppArmor 288
13.6 本章小结 289
第14章 Docker API 290
14.1 关于Docker API 290
14.1.1 通用操作接口 290
14.1.2 关于RESTful 291
14.1.3 Docker API的优势 292
14.1.4 Docker API的分类 293
14.2 使用Docker Remote API 293
14.2.1 关于Docker Remote API 294
14.2.2 Docker Remote API的版本 299
14.2.3 通过Remote API列出容器 300
14.2.4 通过Remote API列出镜像 302
14.3 使用Docker Registry API 303
14.3.1 关于Docker Registry API 304
14.3.2 Docker Registry API的主要功能 304
14.3.3 Docker Registry API的版本 305
14.3.4 通过Registry API拉取镜像 306
14.3.5 通过Registry API推送镜像 307
14.4 本章小结 309
第15章 管理工具 310
15.1 Docker Compose 310
15.1.1 Docker Compose简介 311
15.1.2 安装Docker Compose 313
15.1.3 Docker Compose配置文件 314
15.1.4 常用的Docker Compose命令 315
15.2 Docker Machine 318
15.2.1 Docker Machine简介 318
15.2.2 安装Docker Machine 320
15.2.3 Docker Machine常见命令 321
15.3 Docker Swarm 322
15.3.1 Docker Swarm简介 322
15.3.2 Docker Swarm结构 323
15.3.3 使用Docker Swarm 323
15.3.4 Docker Swarm常见命令 325
15.4 本章小结 327
第16章 Docker的技术架构 328
16.1 命名空间 328
16.1.1 关于Linux命名空间 328
16.1.2 命名空间的系统调用 329
16.1.3 命名空间的分类 330
16.2 控制组 332
16.2.1 关于Linux控制组 332
16.2.2 Cgroups的组成 333
16.2.3 容器与控制组 334
16.3 联合文件系统 336
16.3.1 关于UFS 336
16.3.2 Docker中的UFS 337
16.4 Docker Engine架构 338
16.4.1 Docker Engine的组成结构 338
16.4.2 Docker Daemon 339
16.4.3 Docker CLI 342
16.5 本章小结 344
Before the speech
In the fast-moving world of the Internet, there are always new trend-setting technologies emerging, and in recent years Docker has become one of those technologies. As a program deployment scheme that has attracted much attention in recent years, Docker realizes the rapid deployment of programs and provides a powerful help for the deployment in distributed scenarios. In the field of cloud computing and virtualization, Docker, a project born only a few years ago, is only a newborn. In terms of functional integrity and stability, Docker is not as good as other projects that have stood the test of history. However, the reason why Docker has become a recognized excellent project in the industry after only a few years of success lies in the fact that Docker truly solves the pain point of distributed deployment efficiency in the industry. The new distributed deployment scheme provided by Docker not only significantly reduces the extra work brought by adaptation to the environment in the deployment process, but also fully weakens the impact of virtualization programs on performance in the virtualization process, like other virtualization schemes. Making the efficiency of programs running in Docker comparable to those running directly on a real operating system. However, Docker is popular not only for the changes it brings in the field of deployment, but also for the fact that it can get through the development, testing, operation and maintenance and create a unified operating environment for the development process of the whole project. Because Docker provides a very lightweight container virtualization scheme, Docker can run in the system with very low consumption. This enables us not only to use Docker to deploy programs in the server, but also to use Docker to build the program running environment in the local system during development. Docker was born only a few years ago, and its development and iteration speed is very fast, so its related teaching materials are relatively scarce, especially Chinese literature. Compared with other technologies that have been developing for decades, there are very few. On the basis of helping readers who want to know and use Docker, this book collects docker-related materials, especially foreign materials that lack Chinese translation. It collects and writes them up, combines them with relevant cases and practices, and provides a shortcut for readers to understand Docker. This book explains and shows Docker concepts, principles, usage methods, practical cases and peripheral tools from different dimensions from the shallow to the deep. Developers of different positions or with different understandings of Docker can get the knowledge they want from it. Although the book cannot comprehensively describe all the functions and features of Docker, systematic knowledge combing and the combination of theory and practice provide effective help and guidance for readers to understand and use Docker. Whether you see this book as an introduction to Docker, or as a tool manual to improve Docker knowledge, it will bring you good results. Due to the author’s level and time limit, this book inevitably has omissions and improper place, please correct. This book features By the shallow and deep, suitable for different knowledge level of readers The book covers the basic concept of the Docker and routine use of methods, common server program in the Docker structures, and the practice of using, the summary of security policy and auxiliary tools such as knowledge, it step by step, for different readers different intellectual feast. For the key knowledge in Docker, the necessary and commonly used operation methods and strategies, the book does not spare any ink to fully and even repeatedly elaborate and demonstrate. And the knowledge points that can be extended, although due to space limitation can not be explained in detail, are also listed one by one, for everyone to consult by themselves, for extended reading. The chapters of this book are clear and clear, so that readers can gradually master Docker knowledge, which is a rare Docker handbook and teaching material. This book is interspersed with many demonstrations of Docker usage methods, and provides special chapters to demonstrate Docker practice. Through the guidance of these operation examples, readers can avoid armchair reading, but also make the knowledge between chapters can be connected by these demonstrations, can reduce the phenomenon of disjointed knowledge. As for the explanation of theoretical knowledge, the book is by no means a rigid dogmatic enumeration, nor a simple summary by piling up proprietary words. Instead, obscure knowledge is presented in a life-like way through popular language, making it easier for readers, especially beginners of Docker, to understand Docker. To keep up with The Times and compile Docker with the latest information is an emerging and rapidly developing technology. It has iterated dozens of versions only a few years after its birth. Because Docker is constantly optimized, improved and supplemented in the process of iteration, there are great differences in functions and usage methods between different versions. Therefore, fresh first-hand materials must be used to learn Docker. In the process of writing, this book collected and referred to a lot of the latest materials, especially extracted a lot of the latest features and usage methods of Docker from Docker official documents, and summarized Docker architecture logic from Docker technical instructions and source code. Because this book is completed on the basis of collecting and combing these brand-new materials, it can provide strong support for everyone to learn Docker. Content and System Structure The book is mainly divided into three parts, which respectively introduce the knowledge concept and use method of Docker to readers from the perspective of foundation, practice and improvement. The first part is the foundation, covering the contents of chapters 1 to 5. In the basic chapter, we will explain the history and basic concepts of Docker, and introduce the most common and basic methods of using Docker. Chapter 1 Initial Docker This chapter introduces and presents the new virtualization solution of Docker step by step from the development history and status quo of virtualization and container technology. In addition to introducing the composition and development history of Docker to readers, we will also compare Docker with previous deployment and virtualization schemes, analyze the advantages of using Docker, and introduce common scenarios suitable for using Docker. In addition, we will teach you how to install Docker on several commonly used operating systems. Chapter 2 Image and Warehouse This chapter starts from the concept of Docker image, explains the structural characteristics and composition forms of Docker image, compares the similarities and differences between Docker image and images in other virtualization schemes, and introduces common Docker image management methods to readers. In addition, we will also introduce how to use Docker’s unique image warehouse to store, share and migrate images, and how to use Docker Hub image warehouse officially provided by Docker. Chapter 3 Managing and Using Containers This chapter mainly introduces the core of Docker, that is, the implementation of containers in container technology. This chapter will cover the common operation methods of adding, running, stopping, and deleting containers. It will also show you how to check the running status of containers and how to operate in containers. In addition, this chapter will cover how to migrate containers. Chapter 4 Data Volume and Network This chapter introduces the container network and data volume modules provided by Docker, starting from the exchange of container network data and file data. In the section on data volumes, you can learn the basic concepts of data volumes and how to create or mount a data volume from a host machine. In the section on container networks, readers can learn the basics of container networks and how to let external networks access containers or implement network communication between containers. Chapter 5 Making An Image This chapter mainly introduces how to build a Docker image by writing Dockerfile as required. After showing you how to package your application into an image, we also went through how to write a Dockerfile and the instructions that might be used. The second part is practice, which consists of chapters 6 to 11. In the practice chapter, we will practice the use of common server programs in Docker based on the knowledge learned in the basic chapter. Chapter 6 SSH Service This chapter mainly shows the operation mode of SSH service in Docker container, introduces the role of SSH service in Docker, and leads readers to build SSH service in Docker container, and the practice of building Docker image containing SSH service. Chapter 7 Web Server This chapter first briefly introduces Web services and common programs that can provide Web services, and also builds several common Web service programs, Apache, Nginx and Tomcat, respectively in Docker container. These Web service programs will be packaged into Docker images by writing dockerfiles. Chapter 8 Database Program This chapter gives a brief introduction to the most popular open source relational database MySQL and non-relational database MongoDB, shows how to use them in Docker containers, and also mentions how to make these databases provide services to the outside. We will also build these database software into images through Dockerfile for easy use in Docker. Chapter 9 Caching Tools This chapter begins by explaining the value of using caching tools on your server and introduces Memcached and Redis, two popular tools for handling caching. Once you’ve learned how to use Memcached and Redis, you’ll deploy them into Docker containers and wrap them into Docker images through the scaffolding process. Chapter 10 Dynamic Handlers This chapter introduces Java, PHP, Python, and Node.js, which are commonly used to handle Web requests, and explains how to install or build these applications in a Docker container. After understanding the process of installing or building these programs in containers, we will also package these software into independent Docker images through Dockerfile. Chapter 11 Comprehensive exercise On the basis of the previous practice, this chapter will practice the Web service program, database program, cache tools and dynamic processing program, through the Docker container to run their combination, explain how to build and run a complete set of Web service system through Docker. The third part is the improvement, which is summarized in chapters 12 to 16. In the improvement chapter, we mainly studied and explored some more in-depth usage methods, concepts and principles of Docker. Chapter 12 Network Advancement Based on the basic concepts and usage methods of Docker network introduced before, this chapter further introduces the implementation method of Docker network, expounds the underlying architecture of Docker network and the concept of container network model, and specially introduces the commands used to manage container network. In addition, this chapter introduces readers to deeply customized Docker container network configuration and control. Chapter 13 Security Reinforcement Starting from the underlying isolation mechanism of Docker, this chapter describes how the isolation mechanism ensures that the programs in the container do not interfere with each other, and from this, discusses the ways and principles of controlling the use of resources in the container. We also introduce how to control program permissions and prevent possible attacks and damages through the kernel security mechanism and related security protection procedures. In addition, we will show the security policies and defenses commonly used in Docker. Chapter 14 Docker API This chapter mainly explains the most basic and most important way of Docker to communicate with the outside world, namely Docker API. After introducing the implementation and classification of Docker API, we will extract the Docker Remote API, which is most commonly used for managing Docker core module, and the Docker Registry API, which is used for interacting with images in Remote image warehouse, for special explanation and demonstration. Chapter 15 Management Tools This chapter mainly shows Docker Compose, Docker Machine, Docker S
This article was automatically published by ArtiPub