文章目录
  1. 1. Shipyard 部署
  2. 2. 增加 Shipyard 节点
  3. 3. 管理容器

Shipyard 是一个基于 Web 的 Docker 管理工具,支持多 host,可以把多个 Docker host 上的 containers 统一管理;可以查看 images,甚至 build images;并提供 RESTful API 等等。

Shipyard 的部署方法也处于不断改进中,原先之前采用shipyard/deploy1方法来部署Shipyard的方法已经不再被官方推荐了。现在部署 Shipyard 的方法是使用 shipyard-project 的脚本2

Shipyard 部署

部署前,需要修改 Docker 的配置,在/etc/default/docker中增加如下配置,

1
-H=unix:///var/run/docker.sock -H=tcp://0.0.0.0:2375

然后开始正式部署 Shipyard,获取最新的 Shipyard 的部署脚本,

1
2
curl -sSL https://shipyard-project.com/deploy > shipyard-deploy.sh
chmod +x shipyard-deploy.sh

如果只使用默认的参数,可以如下启动 Shipyard,本机地址是 192.168.2.201,

1
2
3
4
5
6
7
8
9
10
11
12
13
$ cat shipyard-deploy.sh| bash -s
Deploying Shipyard
-> Starting Database
-> Starting Discovery
-> Starting Cert Volume
-> Starting Proxy
-> Starting Swarm Manager
-> Starting Swarm Agent
-> Starting Controller
Waiting for Shipyard on 192.168.2.201:8080
.........
Shipyard available at http://192.168.2.201:8080
Username: admin Password: shipyard

由于 iptables 的规则,Shipyard 会被防火墙阻挡,启动之后还需要清理 iptables 的规则,

1
2
iptables -t nat -F
iptables -F

否则会访问出错。如果需要关闭 Shipyard,仍然是使用 Shipyard 的脚本,

1
2
3
4
5
6
7
8
9
10
$ cat shipyard-deploy.sh| ACTION=remove bash -s
Removing Shipyard
-> Removing Database
-> Removing Discovery
-> Removing Cert Volume
-> Removing Proxy
-> Removing Swarm Agent
-> Removing Swarm Manager
-> Removing Controller
Done

启动后即可用浏览器访问本地8080端口登陆,默认的用户名密码是“admin/shipyard”。

增加 Shipyard 节点

Shipyard 可以管理多个宿主机,这在 Shipyard 中被称为节点。增加节点的方法也是使用相同的部署脚本,

在另一台宿主机(IP 192.168.2.202)中运行,

1
cat ./shipyard-deploy.sh | ACTION=node DISCOVERY=etcd://192.168.2.201:4001 PROXY_PORT=2376 bash -s

运行之后也需要清理 iptables 规则。然后在 Shipyard 的管理网页上的“Nodes”栏中,即可看以下画面,

有2个节点目前受 Shipyard 管理。

管理容器

Shipyard 的主要功能还是管理容器,例如,新增容器,

使用中发现,Shipyard 似乎不支持网页上部署其他节点的容器,只能部署本节点的。容器管理的功能所有节点都一样,如下,部署了2个 Mysql 容器,

可能这个版本的 Shipyard 有 bug,当前 Shipyard 已经包含两个节点,且两个节点上都有mysql:latest的镜像,但是在 images 栏中,Nodes 列并未显示,如下,

图中,ID 为ea0aca21950d的 Mysql 镜像是在 192.168.2.202 上,ID 为a07681abeb6c的镜像是在 192.168.2.201 上。

文章目录
  1. 1. Shipyard 部署
  2. 2. 增加 Shipyard 节点
  3. 3. 管理容器

欢迎来到Valleylord的博客!

本博的文章尽量原创。