【备忘】使用 Docker Machine 创建虚拟机的脚本及参数

来源:互联网 发布:淘宝大熊哥佛牌怎么样 编辑:程序博客网 时间:2024/05/20 06:49

# 1.使用Docker Machine创建virtualBox虚拟机的命令:

$docker-machine create \

--driver virtualbox \

--virtualbox-cpu-count "1" \

--virtualbox-disk-size "20000" \

--virtualbox-memory "1024" \

--engine-registry-mirror https://registry.docker-cn.com \

--engine-registry-mirror=https://2lqq34jg.mirror.aliyuncs.com \

test1

 

 

# 2.以下只用163的镜像加速器创建Docker虚拟机:

$ docker-machine create \

-d virtualbox \

--virtualbox-disk-size=20000 \

--virtualbox-memory=1024 \

--virtualbox-cpu-count=1 \

--engine-insecure-registry=192.168.99.102:5000 \

--engine-registry-mirror=http://hub-mirror.c.163.com \

test2

 

# 执行docker pull xxx下载Docker镜像一样飞快!!!

 

 

# 3.多个(--engine-registry-mirror)参数可以同时使用:

$ docker-machine create \

-d virtualbox \

--virtualbox-disk-size=50000 \

--virtualbox-memory=2048 \

--virtualbox-cpu-count=2 \

--engine-insecure-registry=192.168.99.102 \

--engine-registry-mirror=http://ab330b6b.m.daocloud.io \

--engine-registry-mirror=https://2lqq34jg.mirror.aliyuncs.com \

--engine-registry-mirror=http://hub-mirror.c.163.com \

--engine-registry-mirror=https://pee6w651.mirror.aliyuncs.com \

test3

 

# 使用多个加速器以后,下载Docker镜像飞快!!!



# 4. Docker Machine 创建VM时,使用--driver virtualbox 驱动,可用的参数:


   --virtualbox-boot2docker-url

                        The URL of the boot2docker image. Defaults to the latest available version[$VIRTUALBOX_BOOT2DOCKER_URL]
   --virtualbox-cpu-count "1"

                        number of CPUs for the machine (-1 to use the number ofCPUs available)[$VIRTUALBOX_CPU_COUNT]

   --virtualbox-disk-size "20000"

                        Size of disk for host in MB [$VIRTUALBOX_DISK_SIZE]

   --virtualbox-host-dns-resolver

                        Use the host DNS resolver [$VIRTUALBOX_HOST_DNS_RESOLVER]
   --virtualbox-hostonly-cidr "192.168.99.1/24"

                        Specify the Host Only CIDR [$VIRTUALBOX_HOSTONLY_CIDR]
   --virtualbox-hostonly-nicpromisc "deny"

                        Specify the Host Only Network Adapter Promiscuous Mode [$VIRTUALBOX_HOSTONLY_NIC_PROMISC]
   --virtualbox-hostonly-nictype "82540EM"

                        Specify the Host Only Network Adapter Type [$VIRTUALBOX_HOSTONLY_NIC_TYPE]
   --virtualbox-hostonly-no-dhcp

                        Disable the Host Only DHCP Server [$VIRTUALBOX_HOSTONLY_NO_DHCP]
   --virtualbox-import-boot2docker-vm

                        The name of a Boot2Docker VM to import [$VIRTUALBOX_BOOT2DOCKER_IMPORT_VM]
   --virtualbox-memory "1024"

                        Size of memory for host in MB [$VIRTUALBOX_MEMORY_SIZE]
   --virtualbox-nat-nictype "82540EM"

                        Specify the Network Adapter Type [$VIRTUALBOX_NAT_NICTYPE]
   --virtualbox-no-dns-proxy

                        Disable proxying all DNS requests to the host [$VIRTUALBOX_NO_DNS_PROXY]
   --virtualbox-no-share

                        Disable the mount of your home directory [$VIRTUALBOX_NO_SHARE]
   --virtualbox-no-vtx-check

                        Disable checking for the availability of hardware virtualization before the vm is started [$VIRTUALBOX_NO_VTX_CHECK]
   --virtualbox-share-folder

                        Mount the specified directory instead of the default home location. Format: dir:name [$VIRTUALBOX_SHARE_FOLDER]
   --virtualbox-ui-type "headless"

                        Specify the UI Type: (gui|sdl|headless|separate) [$VIRTUALBOX_UI_TYPE]

阅读全文
0 0