单机使用Docker host网络安装consul和registrator
docker consul registrator    2017-07-19 21:01:41    1108   
lightingfire   docker consul registrator

参考文章:http://gliderlabs.com/registrator/latest/user/quickstart/

 

Consul是强一致性的数据存储,使用gossip形成动态集群。它提供分级键/值存储方式,不仅可以存储数据,而且可以用于注册器件事各种任务,从发送数据改变通知到运行健康检查和自定义命令,具体如何取决于它们的输出

Registrator通过检查容器在线或者停止运行状态自动注册和去注册服务,它目前支持etcd、Consul和SkyDNS 2

 

单机运行 consul服务


# docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp --name node4  gliderlabs/consul-server:0.6 -bootstrap -advertise 192.168.10.138

通过http API 查看consul服务

 

# curl 192.168.10.138:8500/v1/catalog/services 

{"consul":[]}

运行 Registrator

# docker run -d  --name=registrator  --net=host  --volume=/var/run/docker.sock:/tmp/docker.sock   gliderlabs/registrator:latest  consul://192.168.10.138:8500

 

Running Redis


# docker run -d -P --name=redis redis

测试Registrator配置是否有效


 
# curl 192.168.10.138:8500/v1/catalog/services 
 
{"consul":[],"redis":[]}


# curl 192.168.10.138:8500/v1/catalog/service/redis

[{"Node":"23dcba46458b","Address":"192.168.10.138","ServiceID":"localhost.localdomain:redis:6379","ServiceName":"redis","ServiceTags":[],"ServiceAddress":"","ServicePort":32772,"ServiceEnableTagOverride":false,"CreateIndex":25,"ModifyIndex":25}] 


# docker rm -f redis redis 
# curl 192.168.10.138:8500/v1/catalog/service/redis 
[]
 
 

 

by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(防止爬虫):http://blog.liuyingguang.cn
OpenBI问答社区:http://openbi.liuyingguang.cn/


Pre: ERROR: rpc error: code = 2 desc = "oci runtime error: could not synchronise with container process:

Next: OpenVPN添加路由无法加入的原因


Table of content