Docker-machine也是以Docker为代表的容器技术,大大简化了Docker主机部署的复杂度,极大的方便了开发者管理分布式Docker主机。可以在任何平台上面进行安装来使用docker技术,现在说说我在mac主机上面安装步骤:
1.直接在mac命令行输入:
curl -L https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && \
chmod +x /usr/local/bin/docker-machine
2. /usr/local/bin/docker-machine 执行一下显示以下:
zhangsongfudeMacBook-Pro:~ zhangsongfu$ /usr/local/bin/docker-machine
Usage: docker-machine [OPTIONS] COMMAND [arg...]
Create and manage machines running Docker.
Version: 0.12.2, build 9371605
Author:
Docker Machine Contributors - <https://github.com/docker/machine>
Options:
--debug, -D Enable debug mode
--storage-path, -s "/Users/zhangsongfu/.docker/machine" Configures storage path [$MACHINE_STORAGE_PATH]
--tls-ca-cert CA to verify remotes against [$MACHINE_TLS_CA_CERT]
--tls-ca-key Private key to generate certificates [$MACHINE_TLS_CA_KEY]
--tls-client-cert Client cert to use for TLS [$MACHINE_TLS_CLIENT_CERT]
--tls-client-key Private key used in client TLS auth [$MACHINE_TLS_CLIENT_KEY]
--github-api-token Token to use for requests to the Github API [$MACHINE_GITHUB_API_TOKEN]
--native-ssh Use the native (Go-based) SSH implementation. [$MACHINE_NATIVE_SSH]
--bugsnag-api-token BugSnag API token for crash reporting [$MACHINE_BUGSNAG_API_TOKEN]
--help, -h show help
--version, -v print the version
Commands:
active Print which machine is active
config Print the connection config for machine
create Create a machine
env Display the commands to set up the environment for the Docker client
inspect Inspect information about a machine
ip Get the IP address of a machine
kill Kill a machine
ls List machines
provision Re-provision existing machines
regenerate-certs Regenerate TLS Certificates for a machine
restart Restart a machine
rm Remove a machine
ssh Log into or run a command on a machine with SSH.
scp Copy files between machines
start Start a machine
status Get the status of a machine
stop Stop a machine
upgrade Upgrade a machine to the latest version of Docker
url Get the URL of a machine
version Show the Docker Machine version or a machine docker version
help Shows a list of commands or help for one command
如果看到这个代表你的docker-machine安装成功。接下来就要安装docker-machine虚机驱动,因为开发和本地使用。我这里使用virtualbox,所以这个虚机安装我就是不说了。大家可以到网上找到这个软件https://www.virtualbox.org
3.新建一个docker-machine,可以使用以下命令:
/usr/local/bin/docker-machine create -d virtualbox --virtualbox-disk-size "50000" dev
当然这个/usr/local/bin/docker-machine create 有很多参数,比如虚机硬盘大小,内存,网络连接相关参数,可以使用以下方式:
/usr/local/bin/docker-machine create --help
可以查看到相关参数加入相关参数以便于自己实际使用
执行这一步会在你的本机生成一个目录/Users/zhangsongfu/.docker/machine/machines/dev,这个目录会下载一个boot2docker.iso以及相关虚机内容,大约在花个5-10分左右主要看你网速来决定。
4.创建完后就是进入这个虚机方式有两种:
创建好后后面会显示一个查看当前这个虚相关配置命令
/usr/local/bin/docker-machine env dev 可能以查看相关虚机信息,比如IP是什么,相关虚机ssh证书文件在哪里,这个虚机目录在哪里。
1)/usr/local/bin/docker-machine ssh dev
2)使用ssh客户端来连接这里我就是命令行中输入:
ssh -i /Users/zhangsongfu/.docker/machine/machines/dev/id_rsa docker@192.168.99.100
5.然后就是可以尽情使用docker这个软件给我们带来的容器世界相关docker相关使用这里先不做介绍。
注意事项:
上面相关使用mac下面已经我在使用多年,当然可以在windows,linux下面也是可以安装和使用。在我们正式环境中如果是centos6可以会跟docker兼容一般,所以会使用docker-machine来部署,centos7下面就可以直接使用YUM来安装。如果你是windows就使用docker-machine好的。相关部署跟我这边使用大部分相关就是下载这个软件时可以会使用如下:
下载软件地址:https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-Windows-x86_64.exe
相关接作就像一个命令来执行就可以了。相关这个平台下面如何使用不做介绍了。
文章评论