gliderlabs/registrator()

//容器ip+端口

docker run -d \–name=registrator \–net=host \–volume=/var/run/docker.sock:/tmp/docker.sock \gliderlabs/registrator:latest \-internal \consul://localhost:18500

//主机ip+端口

docker run -d \ –name=registrator \ –net=host \ –volume=/var/run/docker.sock:/tmp/docker.sock \ gliderlabs/registrator:latest \ -ip 192.168.0.8 \ consul://192.168.0.8:18500

// zipkin

docker run –name zipkin -d -p 9411:9411 -e STORAGE_TYPE=elasticsearch -e ES_HOSTS=192.168.0.8:9200 openzipkin/zipkin

//zipkin-dependencies

docker run –name zipkin-dependencies –env STORAGE_TYPE=elasticsearch –env ES_HOSTS=192.168.0.8:9200 –env ES_INDEX=zipkin –rm=true -e JAVA_OPTS=”-Xmx3550m -Xms3550m” openzipkin/zipkin-dependencies

//consul

# 不启用acl时,可直接执行下面的命令,创建一个只有一个节点的consul集群
sudo docker run -id -expose=[8300,8301,8302,8500,8600] --restart always -p 18300:8300 -p 18301:8301 -p 18302:8302 -p 18500:8500 -p 18600:8600 --name server1 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -server -bootstrap-expect=1 -node=server1 -bind=0.0.0.0 -client=0.0.0.0 -ui -datacenter dc1
# 启用acl是,只需要修改上面-e参数,如下面的命令,其中token_value可自行设置
sudo docker run -id -expose=[8300,8301,8302,8500,8600] --restart always -p 18300:8300 -p 18301:8301 -p 18302:8302 -p 18500:8500 -p 18600:8600 --name server1 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true,"acl": {"enabled": true,"default_policy": "deny","down_policy": "extend-cache","tokens": {"master": "token_value"}}}' consul agent -server -bootstrap-expect=1 -node=server1 -bind=0.0.0.0 -client=0.0.0.0 -ui -datacenter dc1

各参数说明:
-expose:暴露出出来的端口,即consul启动所需的端口:8300,8301,8302,8500,8600
--restart:always表示容器挂了就自动重启
-p:建立宿主机与容器的端口映射
--name:容器名称
-e:环境变量,这里用于对consul进行配置
consul:这是consul镜像名,不是consul命令
agent:容器中执行的命令,各参数含义:
-server:表示节点是server类型
-bootstrap-expect:表示集群中有几个server节点后开始选举leader,既然是单节点集群,那自然就是1了
-node:节点名称
-bind:集群内部通信地址,默认是0.0.0.0
-client:客户端地址,默认是127.0.0.1
-ui:启用consul的web页面管理
-datacenter:数据中心
更多配置参考:https://www.consul.io/docs/agent/options
————————

//容器ip+端口

docker run -d \–name=registrator \–net=host \–volume=/var/run/docker.sock:/tmp/docker.sock \gliderlabs/registrator:latest \-internal \consul://localhost:18500

//主机ip+端口

docker run -d \ –name=registrator \ –net=host \ –volume=/var/run/docker.sock:/tmp/docker.sock \ gliderlabs/registrator:latest \ -ip 192.168.0.8 \ consul://192.168.0.8:18500

// zipkin

docker run –name zipkin -d -p 9411:9411 -e STORAGE_TYPE=elasticsearch -e ES_HOSTS=192.168.0.8:9200 openzipkin/zipkin

//zipkin-dependencies

docker run –name zipkin-dependencies –env STORAGE_TYPE=elasticsearch –env ES_HOSTS=192.168.0.8:9200 –env ES_INDEX=zipkin –rm=true -e JAVA_OPTS=”-Xmx3550m -Xms3550m” openzipkin/zipkin-dependencies

//consul

# 不启用acl时,可直接执行下面的命令,创建一个只有一个节点的consul集群
sudo docker run -id -expose=[8300,8301,8302,8500,8600] --restart always -p 18300:8300 -p 18301:8301 -p 18302:8302 -p 18500:8500 -p 18600:8600 --name server1 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -server -bootstrap-expect=1 -node=server1 -bind=0.0.0.0 -client=0.0.0.0 -ui -datacenter dc1
# 启用acl是,只需要修改上面-e参数,如下面的命令,其中token_value可自行设置
sudo docker run -id -expose=[8300,8301,8302,8500,8600] --restart always -p 18300:8300 -p 18301:8301 -p 18302:8302 -p 18500:8500 -p 18600:8600 --name server1 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true,"acl": {"enabled": true,"default_policy": "deny","down_policy": "extend-cache","tokens": {"master": "token_value"}}}' consul agent -server -bootstrap-expect=1 -node=server1 -bind=0.0.0.0 -client=0.0.0.0 -ui -datacenter dc1

各参数说明:
-expose:暴露出出来的端口,即consul启动所需的端口:8300,8301,8302,8500,8600
--restart:always表示容器挂了就自动重启
-p:建立宿主机与容器的端口映射
--name:容器名称
-e:环境变量,这里用于对consul进行配置
consul:这是consul镜像名,不是consul命令
agent:容器中执行的命令,各参数含义:
-server:表示节点是server类型
-bootstrap-expect:表示集群中有几个server节点后开始选举leader,既然是单节点集群,那自然就是1了
-node:节点名称
-bind:集群内部通信地址,默认是0.0.0.0
-client:客户端地址,默认是127.0.0.1
-ui:启用consul的web页面管理
-datacenter:数据中心
更多配置参考:https://www.consul.io/docs/agent/options