install docker-machine

$ curl -L https://github.com/docker/machine/releases/download/v0.10.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
chmod +x /tmp/docker-machine &&
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine

 

create manager & worker

$  docker-machine create --driver virtualbox manager
Running pre-create checks...
Creating machine...
(manager) Copying /Users/victoria/.docker/machine/cache/boot2docker.iso to /Users/victoria/.docker/machine/machines/manager/boot2docker.iso...
(manager) Creating VirtualBox VM...
(manager) Creating SSH key...
(manager) Starting the VM...
(manager) Check network to re-create if needed...
(manager) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env manager

 

Verify machines are running and get IP addresses

 

$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
manager * virtualbox Running tcp://192.168.99.100:2376 v17.03.0-ce
worker - virtualbox Running tcp://192.168.99.101:2376 v17.03.0-ce

 

MANAGE THE MACHINES FROM A PRE-CONFIGURED SHELL

$ docker-machine env manager
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/victoriabialas/.docker/machine/machines/manager"
export DOCKER_MACHINE_NAME="manager"
export DOCKER_API_VERSION="1.25"
# Run this command to configure your shell:
# eval $(docker-machine env manager)

 

SSH INTO A MACHINE

 

$ docker-machine ssh manager
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| WARNING: this is a build from test.docker.com, not a stable release. Boot2Docker version 1.13.0-rc6, build HEAD : 5ab2289 - Wed Jan 11 23:37:52 UTC 2017
Docker version 1.13.0-rc6, build 2f2d055

 

Create a swarm

Initialize the swarm

$ docker-machine ssh manager
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| WARNING: this is a build from test.docker.com, not a stable release. Boot2Docker version 1.13.0-rc7, build HEAD : b2cde29 - Sat Jan 14 00:29:39 UTC 2017
Docker version 1.13.0-rc7, build 48a9e53

Initialize a swarm

docker@manager:~$ docker swarm init --advertise-addr 192.168.99.100
Swarm initialized: current node (2tjrasfqfu945b7n4753374sw) is now a manager. To add a worker to this swarm, run the following command: docker swarm join \
--token SWMTKN-1-144pfsupfo25h43zzr6b6bghjson8uedxjsndo5vuehqlyarsk-9k4q84axm008whv9zl4a8m8ct \
192.168.99.100:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

Add a worker node to the swarm

Log into the worker machine.

$ docker-machine ssh worker
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| WARNING: this is a build from test.docker.com, not a stable release. Boot2Docker version 1.13.0-rc7, build HEAD : b2cde29 - Sat Jan 14 00:29:39 UTC 2017
Docker version 1.13.0-rc7, build 48a9e53

On the worker, run the join command given as the output of the swarm init command you ran on the manager.

docker@worker:~$ docker swarm join \
> --token SWMTKN-1-144pfsupfo25h43zzr6b6bghjson8uedxjsndo5vuehqlyarsk-9k4q84axm008whv9zl4a8m8ct \
> 192.168.99.100:2377
This node joined a swarm as a worker.

List the nodes in the swarm

docker@manager:~$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
2tjrasfqfu945b7n4753374sw * manager Ready Active Leader
syc46yimgtyz9ljcsfqiurvp0 worker Ready Active

最新文章

  1. Oracle创建自增ID
  2. 【Hawk】入门教程(1)——从URL开始
  3. Http组件的介绍
  4. RDIFramework.NET 框架兼容各种数据库类型事务使用范例参考
  5. 新机上岗 Core i7-4790 @ 3.60GHz 四核 / 16 GB ( 金士顿 DDR3 1866MHz ) / GeForce GTX 970 ( 4 GB / 七彩虹 )
  6. WordPress 3.8.1 /xmlrpc.php拒绝服务漏洞
  7. Android 项目建立步骤
  8. Python 之网络式编程
  9. cout设置输出数据不显示科学计数法
  10. @EnableEurekaServer无法正常import原因是spring-cloud-dependencies版本太低
  11. istio实现对外暴露服务
  12. 完美:利用旧版iCloud更改Apple ID地区
  13. NOIp 2018 D2T1 旅行//未完成
  14. flex对象.show()的时候display变成block
  15. [BZOJ3560]DZY Loves Math V(欧拉函数)
  16. 动态设置progressBar的进度
  17. 验证email是否合法
  18. 时区缩写 UTC, CST, GMT, CEST 以及转换
  19. CSS-cascading stle sheets
  20. ubuntu更新root密码

热门文章

  1. 富文本编辑器UEditor自定义工具栏(三、自定义工具栏功能按钮图标及工具栏样式简单修改)
  2. 用react重构个人网站 3-22
  3. spawn-fcgi运行fcgiwrap
  4. Android 不规则封闭区域填充 手指秒变油漆桶
  5. Dashboard二次开发简明教程
  6. Ubuntu 16.04 为 root 帐号开启 SSH 登录
  7. Django中Middleware中间件
  8. Spark学习之键值对操作总结
  9. Mac PyCharm激活码(转载CSDN的猪哥66文章)
  10. LVM 移除PV步骤