Docker in Practice By Ian Miell2016 | 370 Pages | ISBN: 1617292729 | PDF | 6 MBDocker is impossible to ignore. This lightweight container system is easier to deploy and more flexible than traditional VMs. Built for simplicity and speed, it radically reduces your reliance on manual system administDocker in practiceIAN MIELLAIDAN HOBSON SAYERSMANNINGSHELTER SLANDFor online information and ordering of this and other Manning books, please visitwww.manning.com.ThepublisheroffersdiscountsonthisbookwhenorderedinquantityFor more information, please contactSpecial sales DepartmentManning publications co20 Baldwin roadPOBoⅹ761Shelter island. nY11964Emailorders@manning.com02016 by Manning Publications Co. All rights reservedNo part of this publication may be reproduced, stored in a retrieval system, or transmitted, inany form or by means electronic, mechanical, photocopying, or otherwise, without prior writtenpermission of the publisherMany of the designations used by manufacturers and sellers to distinguish their products areclaimed as trademarks. Where those designations appear in the book, and manningPublications was aware of a trademark claim, the designations have been printed in initial capsOIlIcapsRecognizing the importance of preserving what has been written, it is Mannings policy to havethe books we publish printed on acid-free paper and we exert our best efforts to that endRecognizing also our responsibility to conserve the resources of our planet, Manning books areprinted on paper that is at least 15 percent recycled and processed without the use of elementalchlorineManning publications coDevelopment editor: Cynthia Kane20 Baldwin RoadTechnical development editors: Alain CouniotPO BoX 761and robert WennerShelter island. ny11964Copyeditor: Andy carrollProofreader: Melody dolabTechnical proofreader ose San LeandroTypesetter: Gordan SalinovicCover designer: Marja TudorISBN9781617292729Printed in the united states of america12345678910-EBM-212019181716brief contentsPART 1 DOCKER FUNDAMENTALSDiscovering Docker 32 Understanding Docker-inside the engine room 19PaRt 2 DOCKER AND DEVELOPMENTUsing Docker as a lightweight virtual machine 48Day-to-day docker 655 Configuration management--getting your house inorder 103Part 3 DOCKER AND DEVOPS143Continuous integration: speeding up your developmentpipeline 145Continuous delivery: a perfect fit for Dockerprinciples 169Network simulation: realistic environment testing withoutthe pain 186BRIEF CONTENTSPART 4 DOCKER IN PRODUCTION ...............................................2139 Container orchestration: managing multiple dockercontainers 215Docker and security 262Plain sailing--Docker in production and operationaconsiderations 2912 Docker in production--dealing with challenges 308contentsacknowledgments xixabout the cover illustration xxiiiPART 1 DOCKER FUNDAMENTALSrecoverinDocRe1.1 The what and why of Docker 5What is Docker? 5. What is Docker good for? 7. Keyconcepts 81.2BuIding a docker appligPplicate10Ways to create a new Docker image 11 Writing a Dockerfile 12Building a Docker image 13. Running a Docker container 14cher layering 161.3 Summary 18Understanding Docker--inside the engine room 192.1 Dockers architecture 20CONTENTS2.2 The Docker daemon 21TECHNIQUE I Open your Docker daemon to the world 22TECHNIQUE 2 Running containers as daemons 28TEChNIQue 3 Moving docker to a different partition 262.3 The Docker client 27TECHNIQUE 4 Use socat to monitor Docker APi traffic 27TECHNIQUE 5 Using ports to connect to containers 29TECHNIQUE 6 Linking containers for port isolation 31TECHNIQUE 7 Using Docker in your browser 332.4 Docker registries 34TECHNIQUE 8 Setting up a local Docker registry 352.5 The Docker hub 36TECHNIQUE 9 Finding and running a Docker image 372.6 Summary 39PaRT 2 DOCKER AND DEVELOPMENT413Using Docker as a lightweight virtual machine 433.1 From vm to container 44TECHNIQUE 11 A host-like container 4? Ontainer 44TECHNIQUe 10 Converting your vm to a container 44TECHNIQUE 12 Splitting a system into microservice containers 493.2 Managing services on your containers 52ECHNIOUUE 13Managing thege startup of your containersservices 538.8 Saving and restoring your work 55TECHNIQUE 14 The"save game approach to development 55TECHNIQUE 15 Docker tagging 57TECHNIQUE 16 Sharing images on the Docker Hub 59TECHNIQUE 17 Referring to a specific image in builds 613.4 Environments as processes 62TECHNIQUE 18 The"save game"approach to development 623.5 Summary 644Day-to-day Docker 654.1 Volumes-a persistent problem 66TECHNIQUE 19 Docker volumes-problems of persistence 66TecHnique 20 Distributed volumes with BitTorrent Sync 67CONTENTSTECHNIQUE 21 Retain your containers bash history 69TECHNIQUE 22 Data containers 71TECHNIQUE 23 Remote volume mounting using sshfs 74TECHNIQUE 24 Sharing data over NFS 76TECHNIQUE 25 Dev tools container 784.2 Running containers 79TECHNIQUE 26 Running GUIs within Docker 79TECHNIQUE 27 Inspecting containers 81TEcHnique 28 Cleanly killing containers 83TECHNIQUE 29 USing docker machine to provision Dockerhosts 844.3 Building images 87TECHNIQUE 30 Injecting files into your image using ADD 88TECHNIQUE 31 Rebuilding without the cache 90TECHNIQUE 32 Busting the cache 924. Staying ship-shape 93TECHNIQUE 38 Running Docker without sudo 93TECHNIQUe 34 Housekeeping containers 94TECHNIQUE 35 Housekeeping volumes 95TECHNIQUE 36 Detaching containers without stopping them 97TECHNIQUE 37 Using DockerUI to manage your Dockerdaemon 98TECHNIQUE 38 Generate a dependency graph of your DockerImagesQTECHNIque 39 Direct action-execute commands on yourcontainer 1015 Summary 102Configuration management-getting your house in order 1035.1 Configuration management and Dockerfiles 104TECHNIQUE 40 Create reliable bespoke tools withENTRYPOINT 104TECHNIQUE 41 Avoid package drift by specifying versions in yourbuild 106TECHNIQUE 42 Replacing text with perl-p-i-e 107TECHNIQUE 48 Flattening images 109TECHNIQUE 44 Managing foreign packages with alien 1llTECHNIQUE 45 Reverse-engineer a Dockerfile from an5.2 Traditional configuration management tools withDocker 116TECHNIQUE 46 Traditional: using make with Docker 116