1.swarm安装
swarm安装有很多种服务注册的方式,token、etcd、zookeeper,本文主要以swarm默认的token方式进行安装。因为最新的docker已经集成了swarm,所以从安装docker开始,本文所用操作系统为ubuntu14.04。
IP name service
10.241.81.233 swarm-1 manage
10.241.81.234 swarm-2 worker
10.241.81.235 swarm-3 worker
参考文档:https://store.docker.com/editions/community/docker-ce-server-ubuntu
(1).set up the repository
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
(2)Install the latest version of Docker CE on Ubuntu:
sudo apt-get -y install docker-ce
(3)Run the following command to create a new swarm:
(参考:https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/)
mananger:
# docker swarm init --advertise-addr 10.241.81.233
Swarm initialized: current node (cpds4fjp7vv6ttqm4y77vmhae) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-5gmmq1w6qsm2zm3wfjkx5at3j2a5mwy1k0qjfp16womwgkqeqj-4ttti9ppo6aqebuw4b1m46vo7 \
10.241.81.233:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
worker:
docker swarm join \
--token SWMTKN-1-5gmmq1w6qsm2zm3wfjkx5at3j2a5mwy1k0qjfp16womwgkqeqj-4ttti9ppo6aqebuw4b1m46vo7 \
10.241.81.233:2377
在manage上执行docker node ls,查看node的状态:
# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
7gzxsm1kmzf92bz8tply3j6dj swarm-2 Ready Active
cpds4fjp7vv6ttqm4y77vmhae * swarm-1 Ready Active Leader
ejrnqul66xm1xy62ankhuhvn1 swarm-3 Ready Active
2.安装register及register-web (参考:https://hub.docker.com/r/hyper/docker-registry-web/)
docker run -itd --restart=always -p 5000:5000 --name registry-srv registry:2