docker-machine 是docker官方提供的docker管理工具劫扒。
通過docker-machine可以輕松的做到:
- 在Windows平臺和MAC平臺安裝和運(yùn)行docker
- 搭建和管理多個(gè)docker 主機(jī)
- 搭建swarm集群
create
通過docker-machine create
命令可以創(chuàng)建一臺docker主機(jī)。該命令需要--driver
標(biāo)記來指定所需要的驅(qū)動(dòng)(VirtualBox, DigitalOcean, AWS,等等)杏愤。
$ docker-machine create --driver virtualbox dev
Creating CA: /home/username/.docker/machine/certs/ca.pem
Creating client certificate: /home/username/.docker/machine/certs/cert.pem
Image cache does not exist, creating it at /home/username/.docker/machine/cache...
No default boot2docker iso found locally, downloading the latest release...
Downloading https://github.com/boot2docker/boot2docker/releases/download/v1.6.2/boot2docker.iso to /home/username/.docker/machine/cache/boot2docker.iso...
Creating VirtualBox VM...
Creating SSH key...
Starting VirtualBox VM...
Starting VM...
To see how to connect Docker to this machine, run: docker-machine env dev
創(chuàng)建參數(shù)
docker-machine create
提供了一些參數(shù)可以在所有驅(qū)動(dòng)類型下使用届宠,通過修改這些參數(shù)暮顺,我們可以在很大程度上定制終端的配置過程次酌。
--driver, -d "none" 創(chuàng)建所需驅(qū)動(dòng)類型
--engine-install-url "https://get.docker.com" 定制docker-engine的安裝鏈接 [$MACHINE_DOCKER_INSTALL_URL]
--engine-opt [--engine-opt option --engine-opt option] 創(chuàng)建docker-engine 所需參數(shù)
--engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option] 指定不安全的倉庫地址(沒有使用TLS協(xié)議)
--engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option] 指定鏡像倉庫地址
--engine-label [--engine-label option --engine-label option] 指定創(chuàng)建docker-engine 所用label
--engine-storage-driver 指定docker-engine存儲所用驅(qū)動(dòng)
--engine-env [--engine-env option --engine-env option] 指定docker-engine所需環(huán)境變量
--swarm Configure Machine with Swarm
--swarm-image "swarm:latest" Specify Docker image to use for Swarm [$MACHINE_SWARM_IMAGE]
--swarm-master Configure Machine to be a Swarm master
--swarm-discovery Discovery service to use with Swarm
--swarm-strategy "spread" Define a default scheduling strategy for Swarm
--swarm-opt [--swarm-opt option --swarm-opt option] Define arbitrary flags for swarm
--swarm-host "tcp://0.0.0.0:3376" ip/socket to listen on for Swarm master
--swarm-addr addr to advertise for Swarm (default: detect and use the machine IP)
--swarm-experimental Enable Swarm experimental features
注意
其中有些標(biāo)志是相互關(guān)聯(lián)的擅笔,如果使用docker-machine create
命令時(shí)設(shè)置了其中一個(gè),其余的同樣會被設(shè)置并使用默認(rèn)值