博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Docker machine 多主机管理
阅读量:6658 次
发布时间:2019-06-25

本文共 3132 字,大约阅读时间需要 10 分钟。

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

1、安装docker-machine

设置环境变量;
base=
下载
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 ~]#

2、添加第二台 host主机 (第二台host 配置和yum源和ssh无密码登陆,什么也不用做)

[root@docker ~]# docker-machine create --driver generic --generic-ip-address=192.168.1.40 docker-1
Running pre-create checks...
Creating machine...
(docker-1) 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-1
[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
docker-1 - generic Running tcp://192.168.1.40:2376 v18.05.0-ce
[root@docker ~]#

转载于:https://blog.51cto.com/shyln/2135037

你可能感兴趣的文章
SQL 模糊查询 模糊查找 字符串匹配
查看>>
javascript-demo
查看>>
创新是一项可以学习的技能
查看>>
SpringSecurity学习之基于数据库的用户认证
查看>>
HttpPostedFile 和 HttpPostedFileBase 你真的了解嘛?
查看>>
zepto和jquery的区别
查看>>
【待续】Visual Studio 插件推荐
查看>>
CentOS 7 使用 Realtek 8188eu 上网 (解决 Required key not available)
查看>>
Python集合
查看>>
减治法-插入排序和图的两种查找方式
查看>>
Jquery焦点图实例
查看>>
【语法】【内存管理】retain和release
查看>>
第一天 注册成功
查看>>
小记:Quartz 当 Job 执行时间超过触发间隔时间时所发生的情况
查看>>
leetCode 5. Longest Palindromic Substring
查看>>
神经网络之模块化视角(一)
查看>>
SDUT OJ 学密码学一定得学程序
查看>>
http一次请求过程
查看>>
数据库操作常用命令
查看>>
移动端Bug管理工具——Bugtags
查看>>