Book Image

Docker High Performance - Second Edition

By : Espinosa, Russ McKendrick
Book Image

Docker High Performance - Second Edition

By: Espinosa, Russ McKendrick

Overview of this book

Docker is an enterprise-grade container platform that allows you to build and deploy your apps. Its portable format lets you run your code right from your desktop workstations to popular cloud computing providers. This comprehensive guide will improve your Docker work?ows and ensure your application's production environment runs smoothly. This book starts with a refresher on setting up and running Docker and details the basic setup for creating a Docker Swarm cluster. You will then learn how to automate this cluster by using the Chef server and cookbooks. After that, you will run the Docker monitoring system with Prometheus and Grafana, and deploy the ELK stack. You will also learn best practices for optimizing Docker images. After deploying containers with the help of Jenkins, you will then move on to a tutorial on using Apache JMeter to analyze your application's performance. You will learn how to use Docker Swarm and NGINX to load-balance your application, and how common debugging tools in Linux can be used to troubleshoot Docker containers. By the end of this book, you will be able to integrate all the optimizations that you have learned and put everything into practice in your applications.
Table of Contents (11 chapters)

Inspecting containers with the docker exec command


When troubleshooting servers, the traditional way to debug is to log in and poke around the machine. With Docker, this typical workflow is split into two steps: the first is logging in to the Docker host using standard remote access tools such as SSH, and the second is entering the desired running container's process namespace with the docker exec command. This is useful as a last resort to debug what is happening inside our application.

For most of this chapter, we will troubleshoot and debug a Docker container running HAProxy. The following steps will prepare the sample container service:

  1. First, we will create the configuration for HAProxy named haproxy.cfg with the following content:
defaults
  mode http
  timeout connect 5000ms
  timeout client 50000ms
  timeout server 50000ms

frontend stats
  bind 127.0.0.1:80
  stats enable

listen http-in
  bind *:80
  server server1 www.debian.org:80
  1. Next, we will prepare a Compose file, compose.yml...