I am new to both Docker and Consul, and am trying to get a feel for how containerized apps could use Consul for both service registry and KV pair config management ("configuration").
My understanding was that I could:
- Create an image that runs Consul server, so something like this; then
- Spin up three of these Docker-Consul containers (thus forming a cluster/quorum) on
myvm01.example.com(an Ubuntu VM); then - Refactor my app to use Consul and create a Docker image that runs my app and Consul agent, with the agent configured to join the 3-node quorum at startup. On startup, my app uses the local Consul agent to pull down all of its configurations, stored as KV pairs. It also pulls in registered/healthy services, and uses a local load balancing tool to balance the services it integrates with.
- Run my app's containers on, say,
myvm02.example.com(another Ubuntu VM).
So to begin with, if any of this seems like I am misunderstanding the normal/proper uses of Docker and Consul (sans Registrator), please begin by correcting me!
Assuming I'm more or less correct, I recently stumbled across Registrator and am now even more confused. Registrator seems to be some middleman between your app containers and your Consul (or whatever registry you use) servers.
After reading their Quickstart tutorial, it sounds like what you're supposed to do is:
- Deploy my Consul cluster/quorum containers to
myvm01.example.comlike before - Instead of "Dockerizing" my app to use Consul directly, I simply integrate it with Registrator
- Then I deploy a Registrator container somewhere, and configure it to integrate with Consul
- Then I deploy my app containers. They integrate with Registrator, and Registrator in turn integrates with Consul.
My concerns:
- Is my understanding here correct or way off base? If so, how?
- What is actually gained by the addition of Registrator. It doesn't seem (to the untrained eye at least) like anything more than a layer of indirection between the app and the service registry.
- Will I still be able to leverage Consul's KV config service through Registrator?