码迷,mamicode.com
首页 > 系统相关 > 详细

Docker machine 多主机管理

时间:2018-07-02 14:50:58      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:stat   update   ofo   this   TE   cat   https   执行   添加主机   

我们生产环节中一定是 多host出现的,所以我用到docker-machine 管理工具,实现对多个host上面的docker的管理。

1、安装docker-machine
设置环境变量;
base=https://github.com/docker/machine/releases/download/v0.14.0
下载
curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine
设置环境变量
sudo install /tmp/docker-machine /usr/local/bin/docker-machine
此时可以执行docer-machine 相关指令,验证是否成功
[root@docker ~]# docker-machine --version
docker-machine version 0.14.0, build 89b8332

2、添加主机
1、设置无密码登陆
2、添加主机
[root@docker ~]# docker-machine create --driver generic --generic-ip-address=192.168.1.39 docker
Creating CA: /root/.docker/machine/certs/ca.pem
Creating client certificate: /root/.docker/machine/certs/cert.pem
Running pre-create checks...
Creating machine...
(docker) No SSH key specified. Assuming an existing key at the default location.
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 centos...

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 docker
我们先把自己添加进来
此时查看执行这个命令的动作
[root@docker ~]# ps -ef|grep yum
root 13455 13333 0 20:41 pts/2 00:00:00 /usr/bin/ssh -F /dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none root@192.168.1.39 -p 22 -tt sudo -E yum -y update -x docker-
root 13459 13456 0 20:41 pts/3 00:00:00 sudo -E yum -y update -x docker-

root 13472 13459 5 20:41 pts/3 00:00:13 /usr/bin/python /bin/yum -y update -x docker-*
root 13572 13502 0 20:45 pts/5 00:00:00 grep --color=auto yum
执行这个命令后,在升级安装 dicker 等插件

验证是否添加完成
[root@docker ~]# docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
docker - generic Running tcp://192.168.1.39:2376 v1.13.1
[root@docker ~]#

Docker machine 多主机管理

标签:stat   update   ofo   this   TE   cat   https   执行   添加主机   

原文地址:http://blog.51cto.com/shyln/2135037

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!