使用Docker Toolbox 创建v1.12.6版的Docker虚拟机的方法-注意正确使用本地文件 file:参数的路径名
2017-06-24 00:38
736 查看
使用Docker Toolbox
创建v1.12.6版的Docker虚拟机的方法,
一定要注意正确使用本地文件 file:// 参数的路径名,
之前尝试创建过多次,一直都没有成功过,
无法使用 file:// 参数指定boot2docker.iso 本地文件,
原因居然是Windows路径格式的问题。
# 按照 boot2docker\版本号\boot2docker.iso的目录形式,
# 将所有的ISO都下载到本地的
C:\Users\用户名 这个目录下,
#
# 使用 Docker-machine create -d virtualbox创建虚拟机时,
# --virtualbox-boot2docker-url使用file://参数,一定要加boot2docker.iso
全部的文件名!
# 一定要用Windows下的路径格式! 并且一定要两个反斜杠!!
#
# 官方网页: https://docs.docker.com/machine/drivers/virtualbox/ 显示:
# you could specify --virtualbox-boot2docker-url file://$HOME/Downloads/rc.iso
to test
# 官网示例中使用/斜杠,给人误导!
# 无论只使用目录file://$HOME/boot2docker/v1.12.6/
# 还是在使用file://$HOME/boot2docker/v1.12.6/boot2docker.iso 全部的文件名,都不行.
# 一定要使用file://C:\\Users\\catty\\boot2docker\\v1.12.6\\boot2docker.iso格式,
#
# 估计这个参数是Windows
程序virtualbox调用的,
# 需要使用windows格式的路径才能正确执行。
Win_User="catty"
Docker_Version="v1.12.6"
VM_Name="rancher3"
ISO_File_Path="file://C:\\Users\\$Win_User\\boot2docker\\$Docker_Version\\boot2docker.iso"
docker-machine create \
-d virtualbox \
--virtualbox-memory=1024 \
--virtualbox-cpu-count=1 \
--virtualbox-boot2docker-url=$ISO_File_Path \
--engine-registry-mirror=http://ab330b6b.m.daocloud.io \
--engine-registry-mirror=https://2lqq34jg.mirror.aliyuncs.com \
$VM_Name
eval $(docker-machine env $VM_Name)
docker-machine ls
# 创建Docker v1.12.6虚拟机结束.
附:
Oracle VirtualBox驱动参数及使用说明
https://docs.docker.com/machine/drivers/virtualbox/
Create machines locally using VirtualBox. This driver requires VirtualBox 5+ to be installed on your host. Using VirtualBox 4.3+ should work but will give you a warning. Older versions will refuse to work.
Usage
$ docker-machine create --driver=virtualbox vbox-test
You can create an entirely new machine or you can convert a Boot2Docker VM into a machine by importing the VM. To convert a Boot2Docker VM, you’d use the following command:
$ docker-machine create -d virtualbox --virtualbox-import-boot2docker-vm boot2docker-vm b2d
The size of the VM’s disk can be configured this way:
$ docker-machine create -d virtualbox --virtualbox-disk-size "100000" large
Options
--virtualbox-memory: Size of memory for the host in MB.
--virtualbox-cpu-count: Number of CPUs to use to create the VM. Defaults to single CPU.
--virtualbox-disk-size: Size of disk for the host in MB.
--virtualbox-host-dns-resolver: Use the host DNS resolver. (Boolean value, defaults to false)
--virtualbox-boot2docker-url: The URL of the boot2docker image. Defaults to the latest available version.
--virtualbox-import-boot2docker-vm: The name of a Boot2Docker VM to import.
--virtualbox-hostonly-cidr: The CIDR of the host only adapter.
--virtualbox-hostonly-nictype: Host Only Network Adapter Type. Possible values are
‘82540EM’
(Intel PRO/1000), ‘Am79C973’
(PCnet-FAST III), and ‘virtio’
Paravirtualized network adapter.
--virtualbox-hostonly-nicpromisc: Host Only Network Adapter Promiscuous Mode. Possible options are deny , allow-vms, allow-all
--virtualbox-no-share: Disable the mount of your home directory
--virtualbox-no-dns-proxy: Disable proxying all DNS requests to the host (Boolean value, default to false)
--virtualbox-no-vtx-check: Disable checking for the availability of hardware virtualization before the VM is started
--virtualbox-share-folder: Mount the specified directory instead of the default home location. Format: dir:name
The --virtualbox-boot2docker-url flag takes a few different forms. By default, if no value is specified for this flag, Machine will check locally for a boot2docker ISO. If one is found, that will be used as the ISO for the created machine. If one is not
found, the latest ISO release available on boot2docker/boot2docker will be downloaded and stored locally for future use. Note that this means you must run docker-machine upgrade deliberately on a machine if you wish to update the
“cached”
boot2docker ISO.
This is the default behavior (when --virtualbox-boot2docker-url=""), but the option also supports specifying ISOs by the http:// and file:// protocols. file:// will look at the path specified locally to locate the ISO: for instance,
you could specify --virtualbox-boot2docker-url file://$HOME/Downloads/rc.iso
to test out a release candidate ISO that you have downloaded already. You could also just get an ISO straight from the Internet using the http:// form.
To customize the host only adapter, you can use the --virtualbox-hostonly-cidr flag. This will specify the host IP and Machine will calculate the VirtualBox DHCP server address (a random IP on the subnet between .1 and .25) so it does not clash with the
specified host IP. Machine will also specify the DHCP lower bound to .100 and the upper bound to .254. For example, a specified CIDR of 192.168.24.1/24 would have a DHCP server between 192.168.24.2-25, a lower bound of 192.168.24.100 and upper bound of 192.168.24.254.
ENVIRONMENT VARIABLES AND DEFAULT VALUES
CLI option Environment variable Default
--virtualbox-memory VIRTUALBOX_MEMORY_SIZE 1024
--virtualbox-cpu-count VIRTUALBOX_CPU_COUNT 1
--virtualbox-disk-size VIRTUALBOX_DISK_SIZE 20000
--virtualbox-host-dns-resolver VIRTUALBOX_HOST_DNS_RESOLVER false
--virtualbox-boot2docker-url VIRTUALBOX_BOOT2DOCKER_URL Latest boot2docker url
--virtualbox-import-boot2docker-vm VIRTUALBOX_BOOT2DOCKER_IMPORT_VM boot2docker-vm
--virtualbox-hostonly-cidr VIRTUALBOX_HOSTONLY_CIDR 192.168.99.1/24
--virtualbox-hostonly-nictype VIRTUALBOX_HOSTONLY_NIC_TYPE 82540EM
--virtualbox-hostonly-nicpromisc VIRTUALBOX_HOSTONLY_NIC_PROMISC deny
--virtualbox-no-share VIRTUALBOX_NO_SHARE false
--virtualbox-no-dns-proxy VIRTUALBOX_NO_DNS_PROXY false
--virtualbox-no-vtx-check VIRTUALBOX_NO_VTX_CHECK false
--virtualbox-share-folder VIRTUALBOX_SHARE_FOLDER ~:users
Known Issues
Vboxfs suffers from a longstanding bug causing sendfile(2) to serve cached file contents.
This will often cause problems when using a web server such as nginx to serve static files from a shared volume. For development environments, a good workaround is to disable sendfile in your server configuration.
创建v1.12.6版的Docker虚拟机的方法,
一定要注意正确使用本地文件 file:// 参数的路径名,
之前尝试创建过多次,一直都没有成功过,
无法使用 file:// 参数指定boot2docker.iso 本地文件,
原因居然是Windows路径格式的问题。
# 按照 boot2docker\版本号\boot2docker.iso的目录形式,
# 将所有的ISO都下载到本地的
C:\Users\用户名 这个目录下,
#
# 使用 Docker-machine create -d virtualbox创建虚拟机时,
# --virtualbox-boot2docker-url使用file://参数,一定要加boot2docker.iso
全部的文件名!
# 一定要用Windows下的路径格式! 并且一定要两个反斜杠!!
#
# 官方网页: https://docs.docker.com/machine/drivers/virtualbox/ 显示:
# you could specify --virtualbox-boot2docker-url file://$HOME/Downloads/rc.iso
to test
# 官网示例中使用/斜杠,给人误导!
# 无论只使用目录file://$HOME/boot2docker/v1.12.6/
# 还是在使用file://$HOME/boot2docker/v1.12.6/boot2docker.iso 全部的文件名,都不行.
# 一定要使用file://C:\\Users\\catty\\boot2docker\\v1.12.6\\boot2docker.iso格式,
#
# 估计这个参数是Windows
程序virtualbox调用的,
# 需要使用windows格式的路径才能正确执行。
Win_User="catty"
Docker_Version="v1.12.6"
VM_Name="rancher3"
ISO_File_Path="file://C:\\Users\\$Win_User\\boot2docker\\$Docker_Version\\boot2docker.iso"
docker-machine create \
-d virtualbox \
--virtualbox-memory=1024 \
--virtualbox-cpu-count=1 \
--virtualbox-boot2docker-url=$ISO_File_Path \
--engine-registry-mirror=http://ab330b6b.m.daocloud.io \
--engine-registry-mirror=https://2lqq34jg.mirror.aliyuncs.com \
$VM_Name
eval $(docker-machine env $VM_Name)
docker-machine ls
# 创建Docker v1.12.6虚拟机结束.
附:
Oracle VirtualBox驱动参数及使用说明
https://docs.docker.com/machine/drivers/virtualbox/
Create machines locally using VirtualBox. This driver requires VirtualBox 5+ to be installed on your host. Using VirtualBox 4.3+ should work but will give you a warning. Older versions will refuse to work.
Usage
$ docker-machine create --driver=virtualbox vbox-test
You can create an entirely new machine or you can convert a Boot2Docker VM into a machine by importing the VM. To convert a Boot2Docker VM, you’d use the following command:
$ docker-machine create -d virtualbox --virtualbox-import-boot2docker-vm boot2docker-vm b2d
The size of the VM’s disk can be configured this way:
$ docker-machine create -d virtualbox --virtualbox-disk-size "100000" large
Options
--virtualbox-memory: Size of memory for the host in MB.
--virtualbox-cpu-count: Number of CPUs to use to create the VM. Defaults to single CPU.
--virtualbox-disk-size: Size of disk for the host in MB.
--virtualbox-host-dns-resolver: Use the host DNS resolver. (Boolean value, defaults to false)
--virtualbox-boot2docker-url: The URL of the boot2docker image. Defaults to the latest available version.
--virtualbox-import-boot2docker-vm: The name of a Boot2Docker VM to import.
--virtualbox-hostonly-cidr: The CIDR of the host only adapter.
--virtualbox-hostonly-nictype: Host Only Network Adapter Type. Possible values are
‘82540EM’
(Intel PRO/1000), ‘Am79C973’
(PCnet-FAST III), and ‘virtio’
Paravirtualized network adapter.
--virtualbox-hostonly-nicpromisc: Host Only Network Adapter Promiscuous Mode. Possible options are deny , allow-vms, allow-all
--virtualbox-no-share: Disable the mount of your home directory
--virtualbox-no-dns-proxy: Disable proxying all DNS requests to the host (Boolean value, default to false)
--virtualbox-no-vtx-check: Disable checking for the availability of hardware virtualization before the VM is started
--virtualbox-share-folder: Mount the specified directory instead of the default home location. Format: dir:name
The --virtualbox-boot2docker-url flag takes a few different forms. By default, if no value is specified for this flag, Machine will check locally for a boot2docker ISO. If one is found, that will be used as the ISO for the created machine. If one is not
found, the latest ISO release available on boot2docker/boot2docker will be downloaded and stored locally for future use. Note that this means you must run docker-machine upgrade deliberately on a machine if you wish to update the
“cached”
boot2docker ISO.
This is the default behavior (when --virtualbox-boot2docker-url=""), but the option also supports specifying ISOs by the http:// and file:// protocols. file:// will look at the path specified locally to locate the ISO: for instance,
you could specify --virtualbox-boot2docker-url file://$HOME/Downloads/rc.iso
to test out a release candidate ISO that you have downloaded already. You could also just get an ISO straight from the Internet using the http:// form.
To customize the host only adapter, you can use the --virtualbox-hostonly-cidr flag. This will specify the host IP and Machine will calculate the VirtualBox DHCP server address (a random IP on the subnet between .1 and .25) so it does not clash with the
specified host IP. Machine will also specify the DHCP lower bound to .100 and the upper bound to .254. For example, a specified CIDR of 192.168.24.1/24 would have a DHCP server between 192.168.24.2-25, a lower bound of 192.168.24.100 and upper bound of 192.168.24.254.
ENVIRONMENT VARIABLES AND DEFAULT VALUES
CLI option Environment variable Default
--virtualbox-memory VIRTUALBOX_MEMORY_SIZE 1024
--virtualbox-cpu-count VIRTUALBOX_CPU_COUNT 1
--virtualbox-disk-size VIRTUALBOX_DISK_SIZE 20000
--virtualbox-host-dns-resolver VIRTUALBOX_HOST_DNS_RESOLVER false
--virtualbox-boot2docker-url VIRTUALBOX_BOOT2DOCKER_URL Latest boot2docker url
--virtualbox-import-boot2docker-vm VIRTUALBOX_BOOT2DOCKER_IMPORT_VM boot2docker-vm
--virtualbox-hostonly-cidr VIRTUALBOX_HOSTONLY_CIDR 192.168.99.1/24
--virtualbox-hostonly-nictype VIRTUALBOX_HOSTONLY_NIC_TYPE 82540EM
--virtualbox-hostonly-nicpromisc VIRTUALBOX_HOSTONLY_NIC_PROMISC deny
--virtualbox-no-share VIRTUALBOX_NO_SHARE false
--virtualbox-no-dns-proxy VIRTUALBOX_NO_DNS_PROXY false
--virtualbox-no-vtx-check VIRTUALBOX_NO_VTX_CHECK false
--virtualbox-share-folder VIRTUALBOX_SHARE_FOLDER ~:users
Known Issues
Vboxfs suffers from a longstanding bug causing sendfile(2) to serve cached file contents.
This will often cause problems when using a web server such as nginx to serve static files from a shared volume. For development environments, a good workaround is to disable sendfile in your server configuration.
相关文章推荐
- 【手工解决】使用 DockerToolbox 创建指定版本的 Docker 虚拟机环境
- 创建文件服务器的几种方法(将本地目录发布为网络路径)
- 在Docker Toolbox 终端中使用 vboxmanage.exe 程序在宿主机和虚拟机之间创建共享目录
- javabean操作文件正确,但是Jsp调用javabean时文件路径出错问题解决之JavaBean访问本地文件实现路径无关实现方法
- 使用File.Create等一句代码创建文件的注意一点
- Android中使用file.createNewFile()无法创建文件的问题(例如保存拍照的图片到本地)
- 使用Dockerfile文件创建一个镜像,运行该镜像后并使用浏览器进行访问
- RAC中数据文件创建到了本地路径(非系统表空间) 使用rman转移
- java 使用相对路径读取文件File(类构造方法)
- docker官方镜像下载及使用Dockerfile创建镜像的方法
- Java IO流-File类的使用示例-创建文件夹和文件的正确方法
- (转)javabean操作文件正确,但是Jsp调用javabean时文件路径出错问题解决之JavaBean访问本地文件实现路径无关实现方法
- JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumentException: File distributed.csv must exist and be readable解决方法
- Javascript FileSystemObject 读取/创建本地文件及目录文件夹的方法
- XenServer没有自己的文件系统,也就没有自己的ISO Libery,给我们创建虚拟机带来了不少困扰,使用正文这个方法可以不用先安装FileServer
- 【备忘】使用 Docker Machine 创建虚拟机的脚本及参数
- 文件路径里有空格,使用引号包起来,包法不同,会导致命令行的参数识别出错?
- Image.FromFile方法会锁住文件的解决方法(文件正由另一进程使用,因此该进程无法访问该文件)
- 郁闷N天了,IDFTP发生10054错误后无法继续上传文件,重新创建IDFTP后发生错误:550 cannot create file。请教解决方法
- window平台直接访问unix中文文件路径时的变通方法,使用php发送