Using discovery services

In this section, we will learn how to scale Docker, but in a different way. Previously, we looked at using Docker Compose to do our scaling. In this section, we will look at other technologies that we can utilize to do the scaling for us automatically. There are some discovery services that we can tap into for this usage. We will focus on two of them in this section as they are the more popular ones.

Consul

One of the more popular options for discovery services with regards to Docker is Consul. Consul is an extremely easy-to-use discovery service that offers a lot of options that we can tie this into automatically updating the items in Consul by using a program called Registrator or by automatically taking those items that are updated in Consul and then turning around and updating a configuration file to show those updated items by using the consul-template program. Information about Consul can be found at https://consul.io/. For more information on Registrator, visit http://gliderlabs.com/registrator/latest/. And, to know more about consul-template, refer to https://github.com/hashicorp/consul-template.

Adding these three pieces to your technology arsenal can greatly increase the level of performance and uptime that you can provide. You can add new nodes to a service on the fly, and have the configuration on a particular container be updated on the fly. You can also move the updated nodes into a service and then remove the other ones that aren't updated so that you can provide a method for zero downtime with rolling updates as well. You can also go the other way if you notice something you updated isn't functioning properly. You can roll an older version of something into a discovery service while rolling out the newer version if a bug or security vulnerability is discovered. The possibilities of what you can do with these three pieces can be endless.

etcd

If you are going extremely lightweight with your host environments and using CoreOS, then you are very familiar with etcd. It uses a dynamic configuration registry to do discovery. When etcd is configured on each CoreOS host, they can do key-value distribution and replication, which allows them to discover each other as well as new etcd hosts.

etcd focuses on being:

  • Simple
  • Secure
  • Fast
  • Reliable

To find out more about etcd, refer to https://en.wikipedia.org/wiki/CoreOS#ETCD. You can also visit https://github.com/coreos/etcd, which contains information not just about what etcd can do, but also the ways you can get support for it, roadmap, mailing list, and reported bugs. You can also refer to https://coreos.com/etcd/ and https://github.com/coreos/etcd.

Two of the more well-known projects that are using etcd are:

  • Kubernetes
  • Cloud Foundry

To view other projects that also use etcd, visit https://github.com/search?utf8=%E2%9C%93&q=etcd.

Debugging or troubleshooting Docker

Now that we have our Docker containers running in our production level service, we need to know how we can troubleshoot them—how do we fix common problems with containers, what should we be looking out for, and how can we quickly debug issues that do arise in our environments to avoid any serious downtime? Let's take a look at some of the topics that we can cover.

Docker commands

There are quite a few built-in Docker commands that you can use to help debug and troubleshoot Docker. With focus on running the containers themselves, here are the ones that can help you:

  • Docker history: This lets you view the history of Docker image
  • Docker events: This lets you view the live stream of the container events
  • Docker logs: This lets you view output from a container
  • Docker diff: This lets you view the changes of a container's filesystem
  • Docker stats: This helps you view the live stream of a container's resource usage

GUI applications

The best way to be able to debug or troubleshoot your containers is to have a visual overview of all your containers. There are a few options for you out there that we can use:

Now only these options will allow you to get an overview of the status on all your running containers. You can also manipulate these containers, that is, you can restart them or view the logs for a particular container. While some of the options will do more than others, it is important to review them all to see what is the best fit for what you would like to see and be able to perform.

Resources

While there are a lot of resources out there for Docker, you would want to make sure you are focusing on the following two at all times, as they are the official means by which you can get information or obtain help:

  • Docker documentation: This is an official documentation straight from Docker
  • Docker IRC room: This is the official communication for the Docker community and a place where you can not only get help from others in the Docker community, but also assistance from those who work at Docker
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset