This book is aimed at both systems engineers and developers, with the main focus on getting you to the point where you have a working Docker environment and steering you toward good choices that will support a robust production system. Along the way we’ll explore how to build, test, deploy, and debug Docker applications in both development and production. We’ll also cover a few of the significant orchestration tools in the Docker ecosystem. And finally we’ll round all of that out with some guidance on security and best practices for your container environment.
This book is intended for anyone who is looking to solve the complex workflow problems involved in developing and deploying software to production at scale. If you’re interested in Docker, Linux containers, DevOps, and large, scalable, software infrastructures, then this book is for you.
Today there are many conversations, projects, and articles on the internet about Docker. So why should you devote precious hours to reading this book?
Even though there is a lot of information out there, Docker is a new technology that is evolving very quickly. Even during the time that it took us to write the first release of this book, Docker, Inc. released four versions of Docker plus a few major tools into their ecosystem. In the three years between the first and second editions of this book, the landscape has changed significantly. Docker has become much more stable and instead of suffering from a complete lack of tools, there are now multiple robust choices for almost every aspect of the DevOps workflow. Wrapping your arms around the scope of what Docker provides, understanding how it fits into your workflow, and getting integration right are not trivial tasks.
We have worked for over four years building and operating production Docker platforms for multiple companies. We originally implemented Docker in production only months after its release and can share with you some of the experience we gained from evolving our production platforms since then. Our goal with this book is for you to benefit from this experience by avoiding many of the bumps in the road that we suffered through. Even though the online documentation for the Docker project is very useful, we will attempt to give you a bigger picture and expose you to many of the best practices that we have learned along the way.
When you finish this book, you should have enough information to understand what Docker is, why it’s important, how to get it running, how to deploy your applications with it, and what you can do to get to production. It will hopefully be a quick trip through an interesting technology with some very practical applications.
This book is organized as follows:
Chapters 1 and 2 provide an introduction to Docker, and explain what it is and how you can use it.
Chapter 3 takes you through the steps required to install Docker.
Chapters 4 through 6 dive into the Docker client, images, and containers, exploring what they are and how you can work with them.
Chapter 7 discusses how to debug your images and containers.
Chapter 8 introduces Docker Compose and how it can be used to significantly simplify the process of developing complex container-based services.
Chapter 9 explores the considerations that are important to ensure a smooth transition into production.
Chapter 10 delves into deploying containers at scale in public and private clouds.
Chapter 11 dives into advanced topics that require some familiarity with Docker and can be important as you start to use Docker in your production environment.
Chapter 12 explores some of the core concepts that have solidified in the industry about how to design the next generation of internet-scale production software.
Chapter 13 wraps everything up and ties it with a bow. It includes a summary of what has been covered and how it should help you improve the way you deliver and scale software services.
We realize that many people don’t read technical books front to back and that something like the preface is incredibly easy to skip, but if you’re still with us, here is a quick guide to some different approaches to reading this book:
If you are new to Linux containers, start at the beginning. The first two chapters are intended to help you get your head around the basics of Docker and Linux containers, including what they are, how they work, and why you should care.
If you want to jump right in and install and run Docker on your workstation, then skip to Chapters 3 and 4, which show you how to install Docker, create and download images, run containers, and much more.
If you are familiar with the Docker basics but would like to learn more about how to utilize it for development, take a look at Chapters 5 through 8, which go over a lot of the skills that will make working with Docker on a day-to-day basis easy, and conclude with a thorough exploration of Docker Compose.
If you are already using Docker for development but need some help getting it into production, consider starting with Chapter 9 and continuing on through Chapter 11. These sections delve into deploying containers, leveraging advanced container platforms, and many other advanced topics.
If you are a software or platform architect, you might find Chapter 12 an interesting place to investigate, as we dive into some of the current thinking about designing containerized applications and horizontally scalable services.
The following typographical conventions are used in this book:
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant widthUsed 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 boldShows commands or other text that should be typed literally by the user.
<Constant width in angle brackets>Shows text that should be replaced with user-supplied values or by values determined by context.
This element signifies a tip or suggestion.
This element signifies a general note.
This element indicates a warning or caution.
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/bluewhalebook/docker-up-and-running-2nd-edition.
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 you’re 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 O’Reilly 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 product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Docker: Up & Running, 2e, by Sean P. Kane and Karl Matthias (O’Reilly). Copyright 2018 Sean P. Kane and Karl Matthias, 978-1-492-03673-9.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com.
Safari (formerly Safari Books Online) is a membership-based training and reference platform for enterprise, government, educators, and individuals.
Members have access to thousands of books, training videos, Learning Paths, interactive tutorials, and curated playlists from over 250 publishers, including O’Reilly Media, Harvard Business Review, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Adobe, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, and Course Technology, among others.
For more information, please visit http://oreilly.com/safari.
Please address comments and questions concerning this book to the publisher:
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/docker-up-running-2e.
To comment or ask technical questions about this book, send email to bookquestions@oreilly.com.
For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
We’d like to send a heartfelt thanks to the many people who helped make each edition of this book possible:
Nic Benders, Bjorn Freeman-Benson, and Dana Lawson at New Relic, who went far above and beyond in supporting the first edition, and who ensured that we had time to pursue it.
Roland Tritsch and Nitro Software for supporting Karl’s efforts on the second edition.
Laurel Ruma at O’Reilly who initially reached out to us about writing a Docker book, and Mike Loukides who helped get everything on track.
A special thanks to our first edition editor, Brian Anderson, who ensured that we knew what we were getting into, and guided us along every step of the way.
Nikki McDonald and Virginia Wilson who helped shepherd us through the process of creating a much-needed second edition of this book.
Introducing a new audience to a new technology succinctly takes a special talent. We are very grateful to Lars Herrmann and Laura Frank Tacho for taking time to create a foreword for one of the releases.
Our draft reviewers, who helped ensure that we were on the right track at various points throughout the writing process: Ksenia Burlachenko, who gave us our very first review as well as a full tech review, Andrew T. Baker, Sébastien Goasguen, Henri Gomez, Chelsey Frank, and Rachid Zarouali.
A special callout is due to Alice Goldfuss and Tom Offermann who gave us detailed and consistently useful feedback when we wrote the first edition, and to Mihai Todor for his encouragement, tech review, and full feedback on the second edition.
Gillian McGarvey, Melanie Yarbrough, Justin Billing, and Rachel Monaghan, for their efforts copyediting the manuscript and making it appear like we were actually paying attention in our high school English classes. 517 commas added and counting…
Wendy Catalano and Ellen Troutman, who helped us ensure that the index was useful to all of our readers.
All of our peers at New Relic and Nitro who have been along for the whole Docker ride and provided us with much of the experience that’s reflected here.
Grains of Wrath Brewery, World Cup Coffee, McMenamins Ringlers Pub, Old Town Pizza, A Beer at a Time!, Taylor’s Three Rock pub, and others who kindly let us use their tables and power long after our dishes were empty.
Our families, for being supportive and giving us the required quiet time when we needed it.
And finally to everyone else who encouraged us, gave us advice, or supported us in any way throughout this process.