Skip to content

zbintliff/docker-consul-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Automatic proxified docker setup demo

What is this?

This is a demo using:

  • docker
  • docker-compose for composition
  • consul for service discovery
  • registrator to automatically feed consul with new containers
  • tutum/hello-world as the demo application

How to run

First, launch the consul/registrator base infrastructure with:

$ docker-compose -f consul.yml up -d

Then launch the hello-world application with:

$ docker-compose -f hello.yml up -d

You could also launch both stacks in one go with:

$ docker-compose -f consul.yml -f hello.yml up -d

What is there to see?

Once the stacks are started, you can view:

Scale the app

If you type:

$ docker-compose -f hello.yml scale web=2

You will see:

Health checking

Health checking is implemented at two levels in this stack:

  • haproxy checks that port 80 of each member is up
  • consul checks that the node is up and that / returns a 200 status

If either check fails, the node will not be proxified.

You can test the HTTP check with:

$ docker-compose -f hello.yml scale web=3
$ docker exec -ti $(basename $PWD)_web_2 pkill php-fpm

This will kill the php-fpm master process of the second container:

  • The web_2 node will be shown in error in the consul dashboard
  • The web_2 node will not appear anymore in the haproxy dashboard
  • The service will still run on the two other instances

To fix it, kill the container and scale again:

$ docker rm -f $(basename $PWD)_web_2
$ docker-compose -f hello.yml scale web=3

TODO

  • Test with an overlay network and:

    • get rid of links
    • use consul DNS instead of links
  • Test on swarm

  • Port to an AWS ECS stack with CloudFormation

About

Docker + consul + haproxy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published