Docker is a great tool to build and deploy our applications. Its portable container format allows us to run code anywhere, from our developer workstations to popular cloud computing providers. The workflow around Docker makes development, testing, and deployment easier and faster. However, this is very important to Docker's internals and continuously improving best practices to realize its full potential.
Engineers that have a basic understanding of Docker can read the book sequentially, chapter by chapter. Tech leads who have an advanced understanding of Docker or have deployed applications in production before can go ahead and read Chapter 8, Onto Production, first to understand how Docker can fit in your existing applications. The following is a list of topics covered in this book:
Chapter 1, Preparing Docker Hosts, gives a quick refresher on setting up and running Docker. It documents the setup that you will be using throughout the book.
Chapter 2, Optimizing Docker Images, shows why it is important to tune your Docker images. A few tuning tips will be shown to improve the deployability and performance of our Docker containers.
Chapter 3, Automating Docker Deployments with Chef, shows how to automate the provisioning and setup of Docker hosts. It will discuss the importance of investing in automation and how it facilitates a scalable way of deploying your Docker containers.
Chapter 4, Monitoring Docker Hosts and Containers, gives a walk-through of setting up a monitoring system with Graphite and logging systems with an Elasticsearch-Logstash-Kibana (ELK) stack..
Chapter 5, Benchmarking, is a tutorial on how to use Apache JMeter to create workloads to benchmark the performance of your Docker containers. The chapter reviews the monitoring system you set up in Chapter 4, Monitoring Docker Hosts and Containers, to analyze some Docker application benchmark results, such as response time and throughput.
Chapter 6, Load Balancing, shows you how to configure and deploy an Nginx-based load balancer Docker container. The chapter also gives a tutorial on how to use the load balancer you set up to scale out the performance and deployability of our Docker applications.
Chapter 7, Troubleshooting Containers, illustrates how common debugging tools in a typical Linux system can be used to troubleshoot your Docker containers. They describe how each tool works and how it can read the diagnostics coming from your running Docker containers.
Chapter 8, Onto Production, synthesizes all the performance optimizations you did in the previous chapter and relates what it means to operate any web application in production with Docker.
A Linux workstation with a recent kernel is needed to serve as a host for Docker 1.10.0. This book uses Debian Jessie 8.2 as its base operating system to install and set up Docker.
More details on how to get Docker up and running is covered in Chapter 1, Preparing Docker Hosts.
This book is written for developers and operations people who want to deploy their Docker application and infrastructure to production. If you have learned the basics of Docker already but want to move forward to the next level, then this book is for you.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We will use --link
<source>:<alias>
to create a link from the source container, named source
, to an alias called webapp
."
A block of code is set as follows:
FROM ubuntu:14.04 MAINTAINER Docker Education Team <[email protected]> RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive apt-get \ install -y -q python-all python-pip ADD ./webapp/requirements.txt /tmp/requirements.txt RUN pip install -qr /tmp/requirements.txt ADD ./webapp /opt/webapp/ WORKDIR /opt/webapp EXPOSE 5000 CMD ["python", "app.py"]
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
provider = str(os.environ.get('PROVIDER', 'world'))
return 'Hello '+provider+'!'
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
Any command-line input or output is written as follows:
dockerhost$ docker inspect -f "{{ .NetworkSettings.IPAddress }}" \ source 172.17.0.15 dockerhost$ docker inspect -f "{{ .NetworkSettings.IPAddress }}" \ destination 172.17.0.28 dockerhost$ iptables -L DOCKER Chain DOCKER (1 references) target prot opt source destination ACCEPT tcp -- 172.17.0.28 172.17.0.15 tcp dpt:5000 ACCEPT tcp -- 172.17.0.15 172.17.0.28 tcp spt:5000
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Finally, click on Download Starter Kit."
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>
, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>
, and we will do our best to address the problem.