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. |