Skip to content

zbintliff/docker-consul-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 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

docker_consul_haproxy

How to run

Start the consul/registrator/haproxy stack

First, launch the consul/registrator/haproxy base infrastructure with:

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

You will then be able to see:

Start the application stack

Then launch the hello-world application with:

$ docker-compose up -d

which will let you access:

the web_1 node was also added to:

Scale the app

If you type:

$ docker-compose 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 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 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