实例介绍
Docker in Practice, 2nd Edition
Docker in practice SECOND EDITION IAN MIELL AIDAN HOBSON SAYERS MANNING Shelter Island For online information and ordering of this and other Manning books, please visit www.manning.com.Thepublisheroffersdiscountsonthisbookwhenorderedinquantity For more information, please contact Manning publications co 20 Baldwin Road POBoⅹ761 Shelter island.nY11964 Emailorders@manning.com C2019 by Manning Publications Co. All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electroniC, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps all caps o Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper and we exert our best efforts to that end Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine Manning publications Co Development editor: Jenny Stout 20 Baldwin Road Review editor: Ivan martinovic POBoⅹ761 Project manager: Vincent nordhaus Shelter island.NY11964 Copyeditor Andy carroll Proofreader: Keri hales Technical proofreader: Jose San Leandro Typesetter: Gordan Salinovic Cover designer: Marija Tudor ISBN9781617294808 Printed in the United states of america 12345678910-SP-242322212019 contents preface xiii acknowledgments xv about this book xvi about the cover illustration xix PART I DOCKER FUNDAMENTALS Discovering Docker 3 1.1 The what and why of Docker 4 What is Docker? 5. What is Docker good for? 7 Key concepts 8 1. 2 Building a Docker application 10 Ways to create a new Docker image 11 Writing a Dockerfile 12 Building a Docker image 13. Running a Docker container 14 Docker layering 16 Understanding Docker: Inside the engine room 19 2.1 Docker's architecture 20 2.2 The docker daemon 21 TECHNIQUE 1 Open your docker daemon to the world 22 TECHNIQUE 2 Running containers as daemons 24 TECHNIQUE 3 Moving Docker to a different partition 27 CONTEN 2.3 The docker client 28 TECHNIQUE4 USing socat to monitor Docker API traffic 28 TECHNIQUE 5 USing Docker in your browser 32 TEChnIQUE 6 Using ports to connect to containers 34 TECHNIQUE 7 Allowing container communication 35 TECHNIQUE 8 Linking containers for port isolation 37 2.4 Docker registries 39 TEChnIQUE 9 Setting up a local Docker registry 40 2.5 The Docker hub 41 TECHNIQUE 10 Finding and running a Docker image 42 PaRT 2 DOCKER AND DEVELOPMENT ........o......45 3 Using Docker as a lightweight virtual machine 47 3.1 From m to container 48 TECHNIQUE 11 Converting your VM to a container 48 TECHNIQUE 12 A host-like container 51 TECHNIQUE 19 Splitting a system into microservice containers 54 TECHNIQUE 14 Managing the startup of your containers services 57 3.2 Saving and restoring your work 59 TECHNIQUE 15 The " save game approach: Cheap source control 60 TECHNIQUE 16 Docker tagging 62 TECHNIQUE 17 Sharing images on the Docker Hub 65 TECHNIQUE 18 Referring to a specific image in builds 67 3.3 Environments as processes 68 TECHNIQUE 19 The" save game"approach: Winning at 2048 68 4 Building images 71 4.1 Building images 71 TECHNIQUE 20 Injecting files into your image using ADD 72 TECHNIQUE 21 Rebuilding without the cache 75 TECHNIQUE 22 Busting the cache 76 TECHNIQuE 28 Intelligent cache-busting using build-args 78 TECHNIQUE 24 Intelligent cache-busting using the aDD e81 TECHNIQUE 25 Setting the right time zone in your containers 84 TECHNIQUE 26 Locale management 86 TECHNIQUE 27 Stepping through layers with the image-stepper 90 TECHNIQUE 28 Onbuild and golan 94 CONTENTS Running containers 97 5.1 Running containers 97 TECHNIQUE 29 Running guis within Docker 98 TECHNIQUE 30 Inspecting containers 100 tECHNique 31 Cleanly killing containers 101 TECHNIQUE 32 Using Docker Machine to provision Docker hosts 103 TECHNIQUE 33 Wildcard DNS 107 5.2 Volumes-a persistent problem 108 TECHNIQUE 34 Docker volumes: Problems of persistence 108 TECHNIQUE 35 Distributed volumes with Resilio Sync 110 TECHNIQUE 36 Retaining your container's bash history 112 TECHNIQUE 37 Data containers 114 Technique 38 Remote volume mounting using Sshfs 116 TEChnique 39 Sharing data over nfs 119 TECHNIQUE 40 Dev tools container 121 6 Day-to-day Docker 124 6.1 Staying ship-shape 124 TECHNIQUE 41 Running docker without sudo 125 TECHNIQUE 42 Housekeeping containers 125 TECHNIQUE 43 Housekeeping volumes 127 TECHNIQUE 44 Detaching containers without stopping them 129 TECHNIQUE 45 USing Portainer to manage your Docker daemon 130 TECHNIQUE 46 Generating a dependency graph of your Docker images 131 TECHNIQUE 47 Direct action: Executing commands on your container 133 TECHNIQUE 48 Are you in a Docker container? 134 Configuration management: Getting your house in order 137 7.1 Configuration management and Dockerfiles 138 TECHNIQUE 49 Creating reliable bespoke tools with ENTRYPOINT 138 TECHNIQUE 50 Avoiding package drift by specifying versions 140 TECHNIQUE 5l Replacing text with perl-p-i-e 142 TECHNIQuE 52 Flattening images 143 TECHNIQUE 58 Managing foreign packages with Alien 145 7.2 Traditional configuration management tools with Docker 148 TECHNIQUE 54 Traditional: USing make with Docker 148 TECHNIQUE 55 Building images with Chef solo 151 CONTENTS 7. 3 Small is beautiful 155 TECHNIQUE 56 Tricks for making an image smaller 155 TECHNIQUE 57 Tiny Docker images with Busy Box and alpine 157 TECHNIQuE 58 The go model of minimal containers 159 TECHNIQUE 59 Us ing inotifywait to slim containers 162 TECHNIQUe 60 Big can be beautiful 164 part 3 DOCKER AND DEVOPS..........167 Continuous integration: Speeding up your development pipeline 169 8.1 Docker hub automated builds 170 TECHNIQUE 61 USing the Docker Hub workflow 170 8.2 More efficient builds 173 TECHNIQUE 62 Speeding up I/O-intensive builds with eatmydata 173 TECHNIQUE 68 Setting up a package cache for faster builds 175 TECHNIQUE 64 Headless Chrome in a container 178 TECHNIQUE 65 Running Selenium tests inside Docker 180 8.3 Containerizing your ci process 185 TECHNIQUE 66 Running the Jenkins master within a Docker container 185 TECHNIQUE 67 Containing a complex development environment 188 TECHNIQUE 68 Scaling your Ci with Jenkins Swarm plugin 192 TECHNIQUE 69 Upgrading your containerized Jenkins server afely 195 Continuous delivery: A perfect fit for Docker principles 200 9. 1 Interacting with other teams in the Cd pipeline 201 TECHNIQUE 70 The Docker contract: Reducing friction 201 9.2 Facilitating deployment of Docker images 204 TECHNIQUE 71 Manually mirroring registry images 204 TECHNIQUE 72 Delivering images over constrained connections 206 TEChnIQUE 73 Sharing Docker objects as TAR files 208 9.3 Configuring your images for environments 210 TECHNIQUE 74 Informing your containers with etcd 210 9. 4 Upgrading running containers 214 TECHNIQUE 75 USing confd to enable zero-downtime switchovers 214 CONTENTS Container communication: Beyond manual linking 221 TECHNIQUE 76 A simple Docker Compose cluster 221 TECHNIQUE 77 A SQLite server using Docker Compose 225 10.2 Using Docker to simulate real-world networking 229 TECHNIQUE 78 Simulating troublesome networks with Comcast 230 TECHNIQUE 79 Simulating troublesome networks with Blockade 233 10.3 Docker and virtual networks 237 TECHNIQUE 80 Creating another docker virtual network 238 TECHNIQUE 81 Setting up a substrate network with Weave 241 PART 4 ORCHESTRATION FROM A SINGLE MACHINE TO THE CLOUD 247 77 Apr A primer on container orchestration 249 11.1 Simple single-host Docker 251 TECHNIQUE 82 Managing your hosts containers with systemd 251 TECHNIQUE 88 Orchestrating the startup of your hosts containers 254 11.2 Manual multi-host Docker 257 TECHNIQUE 84 Manual multi-host Docker with Helios 257 11.3 Service discovery: What have we here? 263 TECHNIQUE 85 Using Consul to discover services 264 TECHNIQUE 86 Automatic service registration with Registrat r271 12 The data center as an OS with Docker 275 12.1 Multi-host Docker 276 TECHNIQUE 87 A seamless Docker cluster with swarm mode 276 TECHNIQUE 88 Using a Kubernetes cluster 280 TECHNIQUE 89 Accessing the Kubernetes aPI from within a TECHNIQUE 90 Using Open Shift to run AWS APIs locally 289 TECHNIQUE 91 Building a framework on Mesos 294 TECHNIQUE 92 Micromanaging mesos with Marathon 302 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论