Docker in Practice, Second Edition
Ian Miell and Aidan Hobson Sayers
  • MEAP began June 2017
  • Publication in January 2019 (estimated)
  • ISBN 9781617294808
  • 440 pages (estimated)
  • printed in black & white
free previous edition included

Must have guide to understanding, setup, and administering Docker!

Alex Basile

Docker in Practice, Second Edition presents nearly 120 practical techniques, hand-picked to help you get the most out of Docker. Following a Problem/Solution/Discussion format, you'll walk through specific examples that you can use immediately, and you'll get expert guidance on general techniques you can apply to a whole range of scenarios. You'll tackle server maintenance, Swarm Mode, deployment, experimenting with your containers, and much more. Fully updated with newly-discovered techniques and interesting use cases, Docker in Practice, Second Edition is an essential resource that you'll want to have open on your desk!

Table of Contents detailed table of contents

Part 1: Docker fundamentals

1 Discovering Docker

1.1 The what and why of Docker

1.1.1 What is Docker?

1.1.2 What is Docker good for?

1.1.3 Key concepts

1.2 Building a Docker application

1.2.1 Ways to create a new Docker image

1.2.2 Writing a Dockerfile

1.2.3 Building a Docker image

1.2.4 Running a Docker container

1.2.5 Docker layering

1.3 Summary

2 Understanding Docker: inside the engine room

2.1 Docker’s architecture

2.1.1 The Docker daemon

2.1.2 TECHNIQUE n Open your Docker daemon to the world

2.1.3 TECHNIQUE n Running containers as daemons

2.1.4 TECHNIQUE n Moving Docker to a different partition

2.1.5 TECHNIQUE n Use socat to monitor Docker API traffic

2.1.6 TECHNIQUE n Using Docker in your browser

2.1.7 TECHNIQUE n Using ports to connect to containers

2.1.8 TECHNIQUE n Allowing container communication with user-defined networks

2.1.9 TECHNIQUE n Linking containers for port isolation

2.1.10 TECHNIQUE n Setting up a local Docker registry

2.1.11 TECHNIQUE n Finding and running a Docker image

2.2 Summary

Part 2: Docker and development

3 Using Docker as a lightweight virtual machine

3.1 From VM to container

3.1.1 TECHNIQUE n Converting your VM to a container

3.1.2 TECHNIQUE n A host-like container

3.1.3 TECHNIQUE n Splitting a system into microservice containers

3.1.4 TECHNIQUE n Managing the startup of your container’s services

3.2 Saving and restoring your work

3.2.1 TECHNIQUE n The "save game" approach to development—​cheap source control

3.2.2 TECHNIQUE n Docker tagging

3.2.3 TECHNIQUE n Sharing images on the Docker Hub

3.2.4 TECHNIQUE n Referring to a specific image in builds

3.3 Environments as processes

3.3.1 TECHNIQUE n The "save game" approach to development

3.4 Summary

4 Building Images

4.1 Building images

4.1.1 TECHNIQUE n Injecting files into your image using ADD

4.1.2 TECHNIQUE n Rebuilding without the cache

4.1.3 TECHNIQUE n Busting the cache

4.1.4 TECHNIQUE n Intelligent cache-busting using build-args

4.1.5 TECHNIQUE n Intelligent cache-busting using the ADD directive

4.1.6 TECHNIQUE n Setting the Right Timezone in Your Containers

4.1.7 TECHNIQUE n Locale Management

4.1.8 TECHNIQUE n Step Through Layers With the Image-Stepper

4.1.9 TECHNIQUE n Onbuild and Golang

4.2 Summary

5 Running Containers

5.1 Running containers

5.1.1 TECHNIQUE n Running GUIs within Docker

5.1.2 TECHNIQUE n Inspecting containers

5.1.3 TECHNIQUE n Cleanly killing containers

5.1.4 TECHNIQUE n Using Docker Machine to provision Docker hosts

5.1.5 TECHNIQUE Wildcard DNS

5.2 Volumes—​a persistent problem

5.2.1 TECHNIQUE n Docker volumes—​problems of persistence

5.2.2 TECHNIQUE n Distributed volumes with BitTorrent Sync

5.2.3 TECHNIQUE n Retain your container’s bash history

5.2.4 TECHNIQUE n Data containers

5.2.5 TECHNIQUE n Remote volume mounting using sshfs

5.2.6 TECHNIQUE n Sharing data over NFS

5.2.7 TECHNIQUE n Dev tools container

5.3 Summary

6 Day-to-day Docker

6.1 Staying ship-shape

6.1.1 TECHNIQUE n Running Docker without sudo

6.1.2 TECHNIQUE n Housekeeping containers

6.1.3 TECHNIQUE n Housekeeping volumes

6.1.4 TECHNIQUE n Detaching containers without stopping them

6.1.5 TECHNIQUE n Using Portainer to manage your Docker daemon

6.1.6 TECHNIQUE n Generate a dependency graph of your Docker images

6.1.7 TECHNIQUE n Direct action—​execute commands on your container

6.1.8 TECHNIQUE n Are you in a Docker container?

6.2 Summary

7 Configuration management: getting your house in order

7.1 Configuration management and Dockerfiles

7.1.1 TECHNIQUE n Create reliable bespoke tools with ENTRYPOINT

7.1.2 TECHNIQUE n Avoid package drift by specifying versions in your build

7.1.3 TECHNIQUE n Replacing text with perl -p -i -e

7.1.4 TECHNIQUE n Flattening images

7.1.5 TECHNIQUE n Managing foreign packages with alien

7.2 Traditional configuration management tools with Docker

7.2.1 TECHNIQUE n Traditional: using make with Docker

7.2.2 TECHNIQUE n Building images with Chef Solo

7.3 Small is beautiful

7.3.1 TECHNIQUE n Tricks for making an image smaller

7.3.2 TECHNIQUE n Tiny Docker images with BusyBox and Alpine

7.3.3 TECHNIQUE n The Go model of minimal containers

7.3.4 TECHNIQUE n Using inotifywait to slim containers

7.3.5 TECHNIQUE n Big can be beautiful—​maybe monolithic is what you need?

7.4 Summary

Part 3: Docker and DevOps

8 Continuous integration: speeding up your development pipeline

8.1 Docker Hub automated builds

8.1.1 TECHNIQUE n Using the Docker Hub workflow

8.2 More efficient builds

8.2.1 TECHNIQUE n Speed up I/O-intensive builds with eatmydata

8.2.2 TECHNIQUE n Set up a package cache for faster builds

8.2.3 TECHNIQUE n Headless Chrome in a Container

8.2.4 TECHNIQUE n Running Selenium tests inside Docker

8.3 Containerizing your CI process

8.3.1 TECHNIQUE n Running the Jenkins master within a Docker container

8.3.2 TECHNIQUE n Containing a complex development environment

8.3.3 TECHNIQUE n Scale your CI with Jenkins' Swarm plugin

8.3.4 TECHNIQUE n Upgrade Your Containerized Jenkins Server Safely

8.4 Summary

9 Continuous delivery: a perfect fit for Docker principles

9.1 Interacting with other teams during the CD pipeline

9.1.1 TECHNIQUE n The Docker contract—​reducing friction in your software pipeline

9.2 Facilitating deployment of Docker images

9.2.1 TECHNIQUE n Manually mirroring registry images

9.2.2 TECHNIQUE n Delivering images over constrained connections

9.2.3 TECHNIQUE n Sharing Docker objects as TAR files

9.3 Configuring your images for environments

9.3.1 TECHNIQUE n Informing your containers with etcd

9.4 Upgrading running containers

9.4.1 TECHNIQUE n Using confd to enable zero-downtime switchover

9.5 Summary

10 Network simulation: realistic environment testing without the pain

10.1 Container communication—​beyond manual linking

10.1.1 TECHNIQUE n A simple Docker Compose cluster

10.1.2 TECHNIQUE n A SQLite server using Docker Compose

10.2 Using Docker to simulate real-world networking

10.2.1 TECHNIQUE n Simulating troublesome networks with comcast

10.2.2 TECHNIQUE n Simulating troublesome networks with Blockade

10.3 Docker and virtual networks

10.3.1 TECHNIQUE n Creating another Docker virtual network

10.3.2 TECHNIQUE n Setting up a substrate network with Weave

10.4 Summary

Part 4: Orchestration from a Single Machine to the Cloud

11 A Primer on Container Orchestration

11.1 Simple single-host Docker

11.1.1 TECHNIQUE n Managing your host’s containers with systemd

11.1.2 TECHNIQUE n Orchestrating the startup of your host’s containers with systemd

11.2 Manual Multi-host Docker

11.2.1 TECHNIQUE n Manual multi-host Docker with Helios

11.3 Service discovery: what have we here?

11.3.1 TECHNIQUE n Using Consul to discover services

11.3.3 TECHNIQUE n Automatic service registration with Registrator

11.4 Summary

12 The Data Centre as an OS with Docker

12.1 Multi-host Docker

12.1.1 TECHNIQUE n A seamless Docker cluster with Swarm mode

12.1.2 TECHNIQUE n Using a Kubernetes cluster

12.1.3 TECHNIQUE n Access the Kubernetes API from within a pod

12.1.4 TECHNIQUE n Using OpenShift to run AWS APIs locally

12.1.5 TECHNIQUE n Building a framework on Mesos

12.1.6 TECHNIQUE n Micromanaging Mesos with Marathon

12.2 Summary

13 Docker Platforms

13.1 What is a Docker Platform?

13.2 Motivation

13.3 A Map for Choosing Docker Platforms

13.4 Platform Choice Factors

13.4.1 Factor Definitions

13.4.2 Factor Discussion

13.4.3 Factors Conclusion

13.5 Areas to Consider when Adopting Docker

13.5.1 Security

13.5.2 Build and Ship

13.5.3 Run

13.5.4 Vendors, Organisations, and Products

13.6 Summary

Part 5: Docker in Production

14 Docker and security

14.1 Docker access and what it means

14.1.1 Do you care?

14.2 Security measures in Docker

14.2.1 TECHNIQUE n Constraining capabilities

14.2.2 TECHNIQUE n A 'Bad' Docker Image to Scan

14.3 Securing access to Docker

14.3.1 TECHNIQUE n HTTP auth on your Docker instance

14.3.2 TECHNIQUE n Securing your Docker API

14.4 Security from outside Docker

14.4.1 TECHNIQUE n Reduce a Container’s Attack Surface with docker-slim

14.4.2 TECHNIQUE n Removing Secrets Added During a Build

14.4.3 TECHNIQUE n OpenShift—​an application platform as a service

14.4.4 TECHNIQUE n Using security options

14.5 Summary

15 Plain sailing: Docker in production and operational considerations

15.1 Monitoring

15.1.1 TECHNIQUE n Logging your containers to the host’s syslog

15.1.2 TECHNIQUE n Logging your Docker logs output to the host’s logging system

15.1.3 TECHNIQUE n Monitoring containers with cAdvisor

15.2 Resource control

15.2.1 TECHNIQUE n Restricting the cores a container can execute on

15.2.2 TECHNIQUE n Giving important containers more CPU

15.2.3 TECHNIQUE n Limiting the memory usage of a container

15.3 Sysadmin use-cases for Docker

15.3.1 TECHNIQUE n Using Docker to run cron jobs

15.3.2 TECHNIQUE The "save game" approach to backups

15.4 Summary

16 Docker in production: dealing with challenges

16.1 Performance: you can’t ignore the tin

16.1.1 TECHNIQUE n Accessing host resources from the container

16.1.2 TECHNIQUE n Disabling the OOM killer

16.2 When containers leak—​debugging Docker

16.2.1 TECHNIQUE n Debug a container’s network with nsenter

16.2.2 TECHNIQUE n Using tcpflow to debug in flight without reconfiguring

16.2.3 TECHNIQUE n Debugging containers that fail on specific hosts

16.2.3 TECHNIQUE n Extracting a File From an Image

16.3 Summary

About the Technology

Docker's simple idea, wrapping an application and its dependencies into a single deployable package, has continued to drive a revolution in software delivery. Docker is now the foundation of CI and CD pipelines, microservice systems, infrastructure automation, and countless innovative twists on the dev process. As well, Docker boasts an incredibly diverse and rich ecosystem, including Kubernetes, CoreOS, Mesos, OpenShift, and the 100,000+ images available on Docker Hub. The options are limitless; Docker in Practice is your guide to the ideas, techniques, and tools that give you the most return on your time.

What's inside

  • New techniques and the latest best practices
  • Continuous integration and delivery
  • Swarm Mode services and routing mesh
  • The Kubernetes orchestration tool
  • Streamlining your cloud workflow
  • Navigating the Docker ecosystem

About the reader

Written for developers and engineers using Docker in production.

About the authors

Ian Miell is the Lead OpenShift Architect at Barclays. Aidan Hobson Sayers is a developer at Hadean. Previously, they used Docker to transform DevOps at OpenBet.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks

An essential read for DevOps transformers!

Robert Kielty

Great recipes style book for Docker.

Travis Wisnasky