uncategorized

Shipyard Docker management

Shipyard是一个高效的Docker容器管理工具,
下面简单介绍一下利用docker-machine创建swarm集群的步骤

利用Docker machine创建3个Node

前提要安装Docker tool box和VirtualBox

1
2
3
docker-machine create --driver virtualbox master
docker-machine create --driver virtualbox slave
docker-machine create --driver virtualbox standby

查看一下容器的环境变量

1
2
3
4
5
6
7
docker-machine env master
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.104:2376"
export DOCKER_CERT_PATH="/Users/acupple/.docker/machine/machines/master"
export DOCKER_MACHINE_NAME="master"
# Run this command to configure your shell:
# eval $(docker-machine env master)

可以看出master这个虚拟机的IP为:192.168.99.104

安装Shipyard contrlller(UI)

1
2
3
4
docker-machine ssh master
mkdir shipyard
cd shipyard
touch start-manager.sh

start-manager.sh文件内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
# Must have root to run Shipyard.
if [[ $EUID -ne 0 ]]
then
echo "This script must be run as root."
exit 1
fi
# Download Shipyard deployment script if it isn't already downloaded.
if [ ! -f deploy ]
then
wget https://shipyard-project.com/deploy
chmod +x deploy
fi
# Start Shipyard manager.
ACTION=deploy
# 重要,指定container用的IP, 默认用eth0 ip, 虚拟机的话是宿主机的IP
IP=192.168.99.104
. deploy

然后运行该脚本

1
sudo ./start-manager.sh

成功的话会输出UI的访问地址: http://192.168.99.104:8080

添加一个node

1
2
3
4
docker-machine ssh node-slave
mkdir shipyard
cd shipyard
touch start-node.sh

启动脚本如下

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
#!/bin/sh
# Exit upon errors.
set -e
# Must have root to run Shipyard.
if [[ $EUID -ne 0 ]]
then
echo "This script must be run as root."
exit 1
fi
# Download Shipyard deployment script if it isn't already downloaded.
if [ ! -f deploy ]
then
wget https://shipyard-project.com/deploy
chmod +x deploy
fi
# Start Shipyard node.
ACTION=node
# IMPORTANT! Change this IP address to the IP address where your Shipyard manager runs.
DISCOVERY=etcd://192.168.99.104:4001
# 指定该node的ip地址,默认用eth0 ip
IP=192.168.99.105
. deploy

运行该脚本

1
sudo ./start-node.sh

完成后,会提示该node已经加入到swarm集群中了,这里最好核对一下IP地址对不对。