Docker machine 多主机管理
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker machine 多主机管理相关的知识,希望对你有一定的参考价值。
我们生产环节中一定是 多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 相关指令,验证是否成功
[[email protected] ~]# docker-machine --version
docker-machine version 0.14.0, build 89b8332
2、添加主机
1、设置无密码登陆
2、添加主机
[[email protected] ~]# 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
我们先把自己添加进来
此时查看执行这个命令的动作
[[email protected] ~]# 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 [email protected] -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 等插件
验证是否添加完成
[[email protected] ~]# docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
docker - generic Running tcp://192.168.1.39:2376 v1.13.1
[[email protected] ~]#
以上是关于Docker machine 多主机管理的主要内容,如果未能解决你的问题,请参考以下文章