参考文章: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
Running Redis
# docker
run
-
d
-P --name=redis redis
测试Registrator配置是否有效
# curl
192.168.10.138:8500/v1/catalog/services
# 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
[]