Table Of ContentDocker Orchestration
A concise, fast-paced guide to orchestrating and deploying
scalable services with Docker
Randall Smith
BIRMINGHAM - MUMBAI
Docker Orchestration
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its
dealers and distributors will be held liable for any damages caused or alleged to be caused
directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: January 2017
Production reference: 1190117
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78712-212-3
www.packtpub.com
Credits
Author Copy Editor
Randall Smith Tom Jacob
Reviewer Project Coordinator
Vincent De Smet Kinjal Bari
Commissioning Editor Proofreader
Pratik Shah Safis Editing
Acquisition Editor Indexer
Rahul Nair Tejal Daruwale Soni
Content Development Editors Graphics
Radhika Atitkar Kirk D'Penha
Sanjeet Rao
Technical Editor Production Coordinator
Bhagyashree Rai Melwyn Dsa
About the Author
Randall Smith is a senior systems administrator at Adams State University. He has been
administering Windows, Linux, and BSD systems since 1999.
He has been active in helping other sysadmins solve problems online and off. He has
presented at the Colorado Higher Ed Computing Organization and Educause conferences
on topics including Linux KVM and Ceph.
In his spare time, Randall streams Let's Play gaming videos at Music Free Gaming on
YouTube and Twitch.
I would like to thank my family for their support and understanding as I disappeared into
my bedroom for hours at a time to write this book. I would like to thank Adams State
University for providing servers used for testing and the opportunity to play with really
cool software such as Docker. Finally, I would like to thank the reviewers and everyone at
Packt who helped make this book possible.
I want to give a special shout-out to all of the developers and companies who have open-
sourced the tools described in this book. You all make it so much much easier for the rest of
us to get the job done. Thank you all so much.
About the Reviewer
Vincent De Smet is a Docker Captain with experience as an IT consultant and a DevOps
engineer in Vietnam and Singapore, respectively. He's also a co-organizer of the Docker
Saigon and Cloud Native Singapore meetups. Vincent loves to deep dive into container
internals, is an active speaker, and publishes articles to the docker-saigon.github.io blog.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a
print book customer, you are entitled to a discount on the eBook copy. Get in touch with us
at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and
eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt
books and video courses, as well as industry-leading tools to help you plan your personal
development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thank you for purchasing this Packt book. We take our commitment to improving our
content and products to meet your needs seriously—that's why your feedback is so
valuable. Whatever your feelings about your purchase, please consider leaving a review on
this book's Amazon page. Not only will this help us, more importantly it will also help
others in the community to make an informed decision about the resources that they invest
in to learn.
You can also review for us on a regular basis by joining our reviewers' club. If you're
interested in joining, or would like to learn more about the benefits we offer, please
contact us: customerreviews@packtpub.com.
Table of Contents
Preface
1
Chapter 1: Getting Started with Docker Orchestration
7
Installing Docker Engine 8
Installing with Docker Machine 9
Starting a host on AWS 9
Starting a host on GCE 12
Starting a host on Microsoft Azure 13
Installing on a running Linux host 15
Introducing Docker-specific distributions 16
CoreOS 16
RancherOS 18
Project Atomic / RHEL Atomic 19
Running single container applications 20
What is running? 24
Inspecting your container 25
Summary 26
Chapter 2: Building Multi-Container Applications with Docker Compose
27
Building an image with Docker Engine 28
Building from a Dockerfile 28
Tagging the image 29
Skipping the build cache 30
Running the image 30
Installing Docker Compose 31
Writing a Docker Compose file 32
Multi-container applications 34
Using environment files 35
Extending compose files 36
Controlling start order 38
Using Docker networks 40
Keeping your data safe in volumes 42
Summary 44
Chapter 3: Cluster Building Blocks – Registry, Overlay Networks, and
Shared Storage
45
Creating a Docker Registry 46
Using the Docker Hub 46
Logging in 47
Working with a repository 49
Automating image builds with Docker Hub 50
Integration with Docker Cloud 52
Using the GitLab Container Registry 52
Installing GitLab on Ubuntu 52
Enabling Docker Registry on a project 54
Introducing the Docker Trusted Registry and Docker Datacenter 55
Building it yourself 55
Connecting containers with overlay networks 57
Using Docker native overlays 57
Working with DNS-SD 58
Publishing services with mesh routing mode 60
Using Weave 60
Installing Weave 61
Connecting containers to Weave 62
Using Flannel 63
Configuring etcd and Flannel 63
Starting a CoreOS cluster with Flannel 65
Connecting to Flannel 66
Using shared network storage for Docker volumes 68
Introducing Ceph 68
Using Ceph with Docker 69
Creating a Docker volume 70
Other shared storage plugins 71
Summary 71
Chapter 4: Orchestration with Docker Swarm
72
Setting up a swarm 72
Initializing a swarm 73
Managing a swarm 74
Adding a node 74
Promoting and demoting nodes 75
Changing node availability 75
Pausing a node 76
Draining a node 76
Activating a node 77
Removing nodes 77
Recovering from a disaster 78
Restarting the full cluster 79
Backup and recovery 79
[ ii ]