Using Docker
by Adrian Mouat
Copyright 2016 Adrian Mouat. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editor: Brian Anderson
- Production Editor: Melanie Yarbrough
- Copyeditor: Christina Edwards
- Proofreader: Amanda Kersey
- Indexer: WordCo Indexing Services
- Interior Designer: David Futato
- Cover Designer: Randy Comer
- Illustrator: Rebecca Demarest
- December 2015: First Edition
Revision History for the First Edition
- 2015-12-07: First Release
- 2016-04-08: Second Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491915769 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Using Docker, the cover image of a bowhead whale, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-91576-9
[LSI]
Dedication
To those who try, whether they fail or succeed.
Preface
Containers are a lightweight and portable store for an application and its dependencies.
Written down by itself, this sounds dry and boring. But the process improvementsmade possible by containers are anything but; used correctly, containers can begame-changing. So persuasive is the lure of the architectures and workflows madepossible by containers that in the span of a year, it feels like every major IT company has gone fromnever having heard of Docker or containers to actively investigating and usingthem.
The rise of Docker has been astonishing. I dont remember anytechnology that has had such a fast and profound effect on the IT industry. Thisbook is my attempt to help you understand why containers are so important,what you stand to gain from adopting containerization, and most importantly,how to go about it.
Who Should Read This Book
This book tries to take a holistic approach to Docker, explaining the reasons forusing Docker and showing how to use it and how to integrate it into asoftware development workflow. The book covers the entire software lifecycle,from development through to production and maintenance.
I have tried to avoid assuming too much of the reader beyond a basic knowledgeof Linux and software development in general. The intended readership isprimarily software developers, operations engineers, and system administrators(particularly those keen to develop a DevOps approach), but technically informedmanagers and enthusiasts should also be able to get something out of this book.
Why I Wrote This Book
I was in the fortunate position to learn about and use Docker while it wasstill in the early stages of its meteoric rise. When the opportunity to writethis book appeared, I leapt at it with both hands. If my scribblings can helpsome of you to understand and make the most of the containerization movement, Iwill have achieved more than I have in years of developing software.
I truly hope that you enjoy reading this book and that it helps you on the pathto using Docker in your organization.
Navigating This Book
This book is roughly organized as follows:
starts by explaining what containers are and why you should be interested in them, before going into a couple tutorial chapters showing the basics of Docker. It concludes with a lengthy chapter explaining thefundamental concepts and technology in Docker, including an overview of thevarious Docker commands.
explains how to use Docker in a software development lifecycle. It starts by showing how to set up a development environment,before building a simple web application that is used as an ongoing examplethroughout the subsequent chapters. This part covers development, testing,and integration, as well as how to deploy containers and how to effectivelymonitor and log a production system.
goes into advanced details and the tools and techniques needed to run multihost clusters of Docker containers safely andreliably. If you are already using Docker and need to understand how to scale upor solve networking and security issues, this is for you.
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This icon signifies a tip, suggestion, or general note.
Warning
This icon indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/using-docker/.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Using Docker by Adrian Mouat (OReilly). Copyright 2016 Adrian Mouat, 978-1-491-91576-9.
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .
Safari Books Online
Note
Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the worlds leading authors in technology and business.
Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.