If you are a developer, a product owner or a project manager, love Docker! It speeds up and eases everything:
- It is a perfect match for 12-Factor applications and microservices development. Do you want Agile Management? Do you want to build large applications? Do you want to keep a clear separation of concerns? Do you want to scale your project like "divide and conquer"?
- It provides a huge amount of images you can easily pull, assemble and enhance to build the best experience to users.
- It is quite agnostic from your infrastructure or cloud provider. It allows to easily scale-out to handle load.
If you are an Ops, you can be even more happy! It is very likely you will get more work and challenges than ever. "Learn as you go", if you want... Not only you should choose and deploy one of the many Docker Infrastructure like Kubernetes, Mesos/Marathon, Nomad, Swarm or AWS ECS but you will soon discover you need more to manage network, service registration/discovery, monitoring, repositories and deployment, blue/green updates, management of monoliths/singletons, secret management, incidents, failures and many more, including integration with other ecosystems.
docker-mate is an introduction to some of the issues you might face when running Docker production; It is
built on top of
docker-compose and focuses on some solutions/components to address them. Hopefully, you will like
some of the demonstrations provided in here, clone the project, open issues and provide new ideas. Hopefully, you will
love docker even more once you've seen some of the fantastic tools people are building to use it. Enjoy.
Service Discovery and Blue/Green Update
Docker network connects containers together so that calling container
A from container
B is usually as easy
as addressing a network alias that could be
container-a. However, when you are deploying containers in
production, you want to be able to scale-out your service and have several containers running the same application at
the same time. So, you will not only want to access container
A from container
B but, say container
A3 from container
B. You will probably also want to provide High Availability so that
A1 fails, it will be withdrawn from the list of usable services. Assuming that works very well, you
should then be able to perform Blue/Green Update by adding new versions of an existing application and removing the
former versions. Last but not least, you would like all of that work without changing a single line of code.
There are a few ways to address service registration, service discovery and service addressing with Docker. One of them
is to rely on Hashicorp Consul as a service registry, Gliderlabs/registrator for automatic container registration and
de-registration as well as on eBay/fabio to load balance service calls, assuming they are HTTP calls. The
discovery directory contains an example of such a configuration with docker-compose.
To demonstrate how it works, we will also rely on a simple application named
simple-api. We will need to deploy 2
of it (1.0 and 2.0) and build the associated images from below:
cd simple-api make docker images simple-api cd ..
To start the demonstration, run:
cd discovery docker-compose up -d
docker-compose.yml contains version 1.0 of
simple-api. Because of the environment variables, Fabio shall
http://127.0.0.1:9999/simple-api URL to the container. To test it, run the command, below in a new
while true; do echo -e "$(curl localhost:9999/simple-api/version 2>/dev/null)" sleep 1 done
In order to perform a Blue/Green update, scaling up the "green" (2.0) version of
simple-api to 2 and scaling
down the "blue" version of it to 0 like below:
docker-compose -f simple-api.yml scale green=2 docker-compose scale blue=0
The monitoring script should show up the ramp-up of the new release as well as the deletion of the previous one. Remove the application container like below:
docker-compose -f simple-api.yml stop docker-compose -f simple-api.yml rm -f
This project also contains some demonstrations and explanations. Explore the section below:
- Reload Variables with Consul-Template (TBD)
- NATS (TBD)
- Prometheus (TBD)