单机使用host网络安装consul、registrator、consul-template构建高可用demo

compose文件:

version: '2'
services:
    consul-server:
        image: gliderlabs/consul-server:0.6
        command: -bootstrap -advertise 192.168.10.138
        hostname: consul-server
        ports:
            - "8400:8400"
            - "8500:8500"
            - "8600:53/udp"

    registrator:
        image: gliderlabs/registrator:latest
        command: consul://consul-server:8500
        hostname: registrator
        depends_on:
            - consul-server
        volumes:
            - /var/run/docker.sock:/tmp/docker.sock
    app:
      image: tutum/hello-world:latest
      environment:
        # Environment variables used by registrator to register services in consul
        SERVICE_NAME: app
        SERVICE_TAGS: sample
      ports:
        - "8081:80"
      depends_on:
        -  consul-template-nginx
# Nginx Load Balancer
     consul-template-nginx:
      image: 1science/nginx:1.9.6-consul
      ports:
        - 80:80
      volumes:
        - ./etc/consul-template:/etc/consul-template
      # Change this section to point on your Consul
      environment:
        CONSUL_URL: consul-server:8500
        FILECONSUL_PREFIX: app
        FILECONSUL_DC: local
        FILECONSUL_BASEPATH: /app/etc
      depends_on:
        - registrator

etc目录附件:

http://pan.baidu.com/s/1boGrouz

你可能感兴趣的:(高可用,docker,consul,registrator,consul-template)