微服务注册发现集群搭建—单机版(Registrator+Consul+Consul-template+nginx)
1.创建模板文件 docker-compose.yml
#backend web application, scale this with docker-compose scale web=3 web: image: tomcat-fhm:1.0 environment: SERVICE_8080_NAME: my-web-server SERVICE_TAGS: backend-1 MY_HOST: host-1 ports: - "8080" #load balancer will automatically update the config using consul-template lb: image: liberalman/nginx-consul-template:latest hostname: lb links: - consulserver:consul ports: - "80:80" consulserver: image: progrium/consul:latest environment: SERVICE_TAGS: consul servers hostname: consulserver ports: - "8300" - "8400" - "8500:8500" - "53" command: -server -ui-dir /ui -data-dir /tmp/consul -bootstrap-expect 1 # 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
docker-compose up
3.关闭
docker-compose down
4.后台运行
docker-compose up -d
5.说明
tomcat-fhm:1.0自己封装的项目镜像