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

Docker Demo on Docker的更多相关文章

  1. openresty redis all in one docker demo

      一个简单的docker demo 集成openresty+ redis,可以实现基于redis的动态修改反向代理的处理 环境准备 docker-compose 文件 version: " ...

  2. Docker构建YApi镜像, Docker安装YApi, Docker部署YApi

    概述 YApi 是高效.易用.功能强大的 api 管理平台,旨在为开发.产品.测试人员提供更优雅的接口管理服务.可以帮助开发者轻松创建.发布.维护 API,YApi 还为用户提供了优秀的交互体验,开发 ...

  3. [转帖]Docker里运行Docker docker in docker(dind)

    Docker里运行Docker docker in docker(dind) http://www.wantchalk.com/c/devops/docker/2017/05/24/docker-in ...

  4. Docker Manager for Docker Swarm deploy

    一.Swarm概述 Swarm是Docker公司在2014年12月初发布的一套较为简单的工具,用来管理Docker集群,它将一群Docker宿主机变成一个单一的,虚拟的主机.Swarm使用标准的Doc ...

  5. 从零开始学习docker之在docker中运行springboot项目

    一.docker环境配置 首先需要一个安装了docker的服务器(本地或者云服务器),如果没有请看上文,传送门---https://www.cnblogs.com/wdfordream/p/12737 ...

  6. 配置 Docker 加速器(Docker Hub Mirror)

    Docker 加速器是什么,我需要使用吗? 使用 Docker 的时候,需要经常从官方获取镜像,但是由于显而易见的网络原因,拉取镜像的过程非常耗时,严重影响使用 Docker 的体验.因此 DaoCl ...

  7. 建立docker私有库(docker registry)(转)

    建立docker私有库(docker registry) 博客分类: docker   我的目标还是无互联网安装,部署内部的docker私有库,目前docker镜像的获得还是需要互联网,将下载好的do ...

  8. 进击的docker 二 : docker 快速入门

    1.安装docker 1.1.安装环境 [root@docker ~]# cat /etc/redhat-release CentOS Linux release (Core) [root@docke ...

  9. 进击的docker 一 : Docker 简介

    Docker简介 1.什么是docker 1.1.docker 起源 开源项目 诞生2013年初 GO语言开发实现 遵从了Apache2.0协议 项目代码在GitHub维护 1.2.docker目标 ...

随机推荐

  1. is not eligible for getting processed by all BeanPostProcessors

    BeanPostProcessor是控制Bean初始化开始和初始化结束的接口.换句话说实现BeanPostProcessor的bean会在其他bean初始化之前完成,BeanPostProcessor ...

  2. Spring cloud整体框架

    研究了一段时间spring boot了准备向spirng cloud进发,公司架构和项目也全面拥抱了Spring Cloud.在使用了一段时间后发现Spring Cloud从技术架构上降低了对大型系统 ...

  3. JavaScript设计模式 Item 6 --单例模式Singleton

    单例模式的定义:保证一个类仅有一个实例,并提供一个访问它的全局访问点. 单例模式是一种常用的模式,有一些对象我们往往只需要一个,比如线程池.全局缓存.浏览器的window对象.在js开发中,单例模式的 ...

  4. jquery开关按钮效果

    .circular1{ width: 50px; height: 30px; border-radius: 16px; background-color: #ccc; transition: .3s; ...

  5. JDBC连接MySQL数据库基础

    主要内容 MySQL的基本操作和基本SQL语法 使用JDBC进行MySQL数据库的开发 使用DriverManager.Connection.PreparedStatement.ResultSet对数 ...

  6. BZOJ_3191_[JLOI2013]卡牌游戏_概率DP

    BZOJ_3191_[JLOI2013]卡牌游戏_概率DP Description   N个人坐成一圈玩游戏.一开始我们把所有玩家按顺时针从1到N编号.首先第一回合是玩家1作为庄家.每个回合庄家都会随 ...

  7. php与html实现交互的基本操作

    今天我们来实现php与html页面注册和登录的效果.中国有句古话叫: 第一步:我们来了解一些php的基本格式. <?php php代码 ?> 第二步:了解php与js的一些基本区别 我们在 ...

  8. Solr的中英文分词实现

    对于Solr应该不需要过多介绍了,强大的功能也是都体验过了,但是solr一个较大的问题就是分词问题,特别是中英文的混合分词,处理起来非常棘手. 虽然solr自带了支持中文分词的cjk,但是其效果实在不 ...

  9. Python3字符串替换replace(),translate(),re.sub()

    Python3的字符串替换,这里总结了三个函数,replace()和translate()和re.sub() replace() replace() 方法把字符串中的 old(旧字符串) 替换成 ne ...

  10. appium---【已解决】【Mac】from appium import webdriver报错提示“Unresolved import webdriver”

    报错提示: from appium import webdriver提示Unresolved import webdriver 报错原因:没有安装Appium_Python_Client 解决办法: ...