Docker可视化界面(Consul+Shipyard+Swarm+Service Discover
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker可视化界面(Consul+Shipyard+Swarm+Service Discover相关的知识,希望对你有一定的参考价值。
前面一篇说到了Docker管理工具-Swarm部署记录,基于这个环境,下面记录下Docker可视化界面部署过程:
1)下载相关镜像 manager-node节点(10.10.172.201) [[email protected] ~]# docker pull progrium/consul [[email protected] ~]# docker pull rethinkdb [[email protected] ~]# docker pull shipyard/shipyard [[email protected] ~]# docker pull gliderlabs/registrator node1和node2节点上 [[email protected] ~]# docker pull progrium/consul [[email protected] ~]# docker pull gliderlabs/registrator 2)启动consul manager-node节点(10.10.172.201) [[email protected] ~]# docker run -d -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -p 8600:53 -p 8600:53/udp -h manager-node --restart=always --name=consul progrium/consul -server -bootstrap -ui-dir=/ui -advertise 10.10.172.201 -client 0.0.0.0 ---------------------------------------------------------------------------------------------- 解释下各个参数: -d 容器在后台运行, detached mode --restart=always 重启模式, always 表示永远 -p 8400:8400 映射 consul的 rpc 端口8400 -p 8500:8500 映射到公共 IP 这样方便我们使用 UI 界面. -p 8600:53/udp 绑定udp 端口53(默认 DNS端口)在 docker0 bridge 地址上. -advertise 10.10.172.201 服务对外公布的 IP, 这里特意设置为10.10.172.201, 否则 service 会显示为内部的容器的 IP 地址, 这样就访问不到了. -client 0.0.0.0 consul 监听的地址. 删除consule命令(下面命令中的"consul"是启动consul命令中的--name后面的设置名) # docker rm -f consul ---------------------------------------------------------------------------------------------- node1节点(10.10.172.202) [[email protected] ~]# docker run -d --restart=always -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -h node1 --name=consul progrium/consul -server -join 10.10.172.201 -advertise 10.10.172.202 -client 0.0.0.0 node2节点(10.10.172.203) [[email protected] ~]# docker run -d --restart=always -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -h node2 --name=consul progrium/consul -server -join 10.10.172.201 -advertise 10.10.172.203 -client 0.0.0.0 3)安装Swarm+Shipyard manager-node节点(10.10.172.201) [[email protected] ~]# docker run -d --restart=always --name shipyard-rethinkdb rethinkdb [[email protected] ~]# docker run -d -p 3375:3375 --restart=always --name shipyard-swarm-manager swarm:latest manage --host tcp://0.0.0.0:3375 consul://10.10.172.201:8500 node1节点(10.10.172.202) [[email protected] ~]# docker run -d --restart=always --name shipyard-swarm-agent swarm:latest join --addr 10.10.172.202:2375 consul://10.10.172.201:8500 node2节点(10.10.172.203) [[email protected] ~]# docker run -d --restart=always --name shipyard-swarm-agent swarm:latest join --addr 10.10.172.203:2375 consul://10.10.172.201:8500 接着再回到manager-node节点上如下操作 [[email protected] web]# docker run -d --restart=always --name shipyard-controller --link shipyard-rethinkdb:rethinkdb --link shipyard-swarm-manager:swarm -p 8080:8080 shipyard/shipyard:latest server -d tcp://swarm:3375 然后就可以在浏览器访问10.10.172.201这台机器的8080端口, 就能看到shipyard的登录页面拉, 默认账户是 admin, 密码shipyard.
[[email protected] ~]# docker service create --replicas 5 --network ngx_net --name my-test -p 80:80 nginx biuilenu8kmpptammif2i4k6w [[email protected] ~]# docker service ls ID NAME REPLICAS IMAGE COMMAND biuilenu8kmp my-test 0/5 nginx [[email protected] ~]# docker service ps my-test ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR 4ir66nukuzg99vqkb5i2oc25v my-test.1 nginx manager-node Running Preparing 10 seconds ago 66yrmx9sx1tjkunh5zbj25mks my-test.2 nginx node1 Running Preparing 10 seconds ago 0tkleq70qrpdybrqc46zshv4u my-test.3 nginx node2 Running Preparing 9 seconds ago 83azzwshy4vyr4fe28pq7s27t my-test.4 nginx node2 Running Preparing 9 seconds ago 11sthowpu7fwiqat8rhcswg7h my-test.5 nginx manager-node Running Preparing 10 seconds ago
4)registrator状态获取 manager-node节点(10.10.172.201) [[email protected] ~]# docker run -d --restart=always --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -ip 10.10.172.201 consul://10.10.172.201:8500 node1节点(10.10.172.202) [[email protected] ~]# docker run -d --restart=always --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -ip 10.10.172.202 consul://10.10.172.202:8500 node2节点(10.10.172.203) [[email protected] ~]# docker run -d --restart=always --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -ip 10.10.172.203 consul://10.10.172.203:8500 参数解释: -v /var/run/docker.sock:/tmp/docker.sock 映射docker的socket到container中的对应位置, 这样 registration 就能监控有哪些服务启动了. consul://localhost:8500 consul 绑定到本地的 consul 接口上
打开http://10.10.172.201:8500,访问consul服务
以上是关于Docker可视化界面(Consul+Shipyard+Swarm+Service Discover的主要内容,如果未能解决你的问题,请参考以下文章