docker-machine批量安装和配置 docker host

前言:
Docker Machine 支持在不同的环境下安装配置 docker host,包括:

Linux 操作系统 - centos、ubuntu

虚拟化平台 - VirtualBox、VMWare、Hyper-V

OpenStack - 公有云、私有云

安装:

官方安装:

curl -L https://github.com/docker/machine/releases/download/v0.13.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

(注:一般来说是装不上去的,你需要FQ)

手动安装:
想办法把docker-machine-Linux-x86_64下载下来。
复制docker-machine-Linux-x86_64,并设置权限

cp docker-machine-Linux-x86_64 /tmp/docker-machine
chmod +x /tmp/docker-machine
cp /tmp/docker-machine /usr/local/bin/docker-machine

使docker-machine正常显示,复制docker-machine.bash

cp docker-machine.bash /etc/bash_completion.d/docker-machine.bash
cp docker-machine-prompt.bash /etc/bash_completion.d/docker-machine-prompt.bash
cp docker-machine-wrapper.bash /etc/bash_completion.d/docker-machine-wrapper.bash

(注:docker-machine.bash从https://github.com/docker/machine/tree/master/contrib/completion/bash
下载)

vim /root/.bashrc

PS1='[\u@\h \W$(__docker_machine_ps1)]\$ '
source /etc/bash_completion.d/docker-machine-wrapper.bash
source /etc/bash_completion.d/docker-machine-prompt.bash
source /etc/bash_completion.d/docker-machine.bash

验证
docker-machine version
docker-machine ls

配置双机互信
node0 172.16.1.1
node1 172.16.1.2
node2 172.16.1.3
(互信百度教程自己配置)

配置完互信,接下来我们开始创建
(这里的创建是为远程机器,进行docker安装配置)
docker-machine create –driver generic –generic-ip-address=172.16.1.2 docker1
docker-machine create –driver generic –generic-ip-address=172.16.1.3 docker2

docker-machine ls
docker-machine config docker1
docker-machine env docker1

docker-machine upgrade 更新 machine 的 docker 到最新版本,可以批量执行:
docker-machine upgrade docker1 docker2

docker-machine scp 可以在不同 machine 之间拷贝文件,比如:
docker-machine scp docker1:/tmp/a docker2:/tmp/b

你可能感兴趣的:(docker,崔格拉斯docker教学指南)