From 39013928eb4b179fdaabaf63dac1b48a70eba972 Mon Sep 17 00:00:00 2001 From: Baohua Yang Date: Tue, 18 Aug 2015 10:47:49 +0800 Subject: [PATCH] Add consul discoverable architecture --- README.md | 3 ++ consul-discovery/docker-compose.yml | 45 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 consul-discovery/docker-compose.yml diff --git a/README.md b/README.md index fca8440a..ac17e420 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ See [https://docs.docker.com/compose/](https://docs.docker.com/compose/). # templates +## consul-discovery +Using consul to make a service-discoverable architecture. + ## mongo_cluster Start 3 mongo instance to make a replica set. diff --git a/consul-discovery/docker-compose.yml b/consul-discovery/docker-compose.yml new file mode 100644 index 00000000..2ee0b11e --- /dev/null +++ b/consul-discovery/docker-compose.yml @@ -0,0 +1,45 @@ +# This compose file will boot a typical scalable lb-backend topology. +# Registrator will listen on local docker socks to maintain all published containers. The information will be written to consulserver +# consul-template will listen on consulserver and update local lb configuration. +# http://yeasy.github.com + + +#backend web application, scale this with docker-compose scale web=3 +web: + image: yeasy/simple-web:latest + environment: + SERVICE_80_NAME: http + SERVICE_NAME: web + SERVICE_TAGS: backend + ports: + - "80" + +#load balancer will automatically update the config using consul-template +lb: + image: yeasy/nginx-consul-template:latest + hostname: lb + links: + - consulserver:consul + ports: + - "80:80" + +consulserver: + image: gliderlabs/consul-server:latest + hostname: consulserver + ports: + - "8300" + - "8400" + - "8500:8500" + - "53" + command: -data-dir /tmp/consul -bootstrap -client 0.0.0.0 + +# listen on local docker sock to register the container with public ports to the consul service +registrator: + image: gliderlabs/registrator:master + hostname: registrator + links: + - consulserver:consul + volumes: + - "/var/run/docker.sock:/tmp/docker.sock" + command: -internal consul://consul:8500 + #command: consul://consul:8500