前面一篇说到了Docker管理工具-Swarm部署记录,基于这个环境,下面记录下Docker可视化界面部署过程:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
1)下载相关惊喜
manager-node节点(182.48.115.237)
[root@manager-node ~]
# docker pull progrium/consul
[root@manager-node ~]
# docker pull rethinkdb
[root@manager-node ~]
# docker pull shipyard/shipyard
[root@manager-node ~]
# docker pull gliderlabs/registrator
node1和node2节点上
[root@node1 ~]
# docker pull progrium/consul
[root@node1 ~]
# docker pull gliderlabs/registrator
2)启动consul
manager-node节点(182.48.115.237)
[root@manager-node ~]
# 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 182.48.115.237 -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 182.48.115.237 服务对外公布的 IP, 这里特意设置为182.48.115.237, 否则 service 会显示为内部的容器的 IP 地址, 这样就访问不到了.
-client 0.0.0.0 consul 监听的地址.
删除consule命令(下面命令中的
"consul"
是启动consul命令中的--name后面的设置名)
# docker rm -f consul
----------------------------------------------------------------------------------------------
node1节点(182.48.115.238)
[root@node1 ~]
# 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 182.48.115.237 -advertise 182.48.115.238 -client 0.0.0.0
node2节点(182.48.115.239)
[root@node2 ~]
# 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 182.48.115.237 -advertise 182.48.115.239 -client 0.0.0.0
3)安装Swarm+Shipyard
manager-node节点(182.48.115.237)
[root@manager-node ~]
# docker run -d --restart=always --name shipyard-rethinkdb rethinkdb
[root@manager-node ~]
# docker run -d -p 3375:3375 --restart=always --name shipyard-swarm-manager swarm:latest manage --host tcp://0.0.0.0:3375 consul://182.48.115.237:8500
node1节点(182.48.115.238)
[root@node1 ~]
# docker run -d --restart=always --name shipyard-swarm-agent swarm:latest join --addr 182.48.115.238:2375 consul://182.48.115.237:8500
node2节点(182.48.115.239)
[root@node2 ~]
# docker run -d --restart=always --name shipyard-swarm-agent swarm:latest join --addr 182.48.115.239:2375 consul://182.48.115.237:8500
接着再回到manager-node节点上如下操作
[root@manager-node 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
然后就可以在浏览器访问182.48.115.237这台机器的8080端口, 就能看到shipyard的登录页面拉, 默认账户是 admin, 密码shipyard.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
4)registrator状态获取
manager-node节点(182.48.115.237)
[root@manager-node ~]
# docker run -d --restart=always --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -ip 182.48.115.237 consul://182.48.115.237:8500
node1节点(182.48.115.238)
[root@node1 ~]
# docker run -d --restart=always --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -ip 182.48.115.238 consul://182.48.115.238:8500
node2节点(182.48.115.239)
[root@node2 ~]
# docker run -d --restart=always --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator -ip 182.48.115.239 consul://182.48.115.239:8500
参数解释:
-
v
/var/run/docker
.sock:
/tmp/docker
.sock 映射docker的socket到container中的对应位置, 这样 registration 就能监控有哪些服务启动了.
consul:
//localhost
:8500 consul 绑定到本地的 consul 接口上
|
打开http://182.48.115.237:8500,访问consul服务