Win10 Docker安装之坑

安装win版的docker前一定要搞清楚:Docker for windows 和 Docker Toolbox的区别。

Docker for Windows是依赖Hyper-V。

Docker ToolBox在安装时会安装VirtualBox,是依赖VirtualBox的。

如果你在安装了Hyper-V的windows10上,再安装Docker ToolBox,将可能非常惨烈。

问题一、如果已经在windows中开启了Hyper-V,启动Docker QuickStart Terminal的时候就会出现。

Running pre-create checks...
Errorwithpre-create check:"This computer is running Hyper-V. VirtualBox won't boot a 64bits VM when Hyper-V is activated. Either use Hyper-V as a driver, or disable the Hyper-V hypervisor. (To skip this check, use --virtualbox-no-vtx-check)"
Looks like something went wronginstep ´Checkingifmachinedefaultexists´...Press any key tocontinue...

解决方案1:
在添加windows功能里面吧Hyper-V功能关闭,重启电脑
解决方案2:
修改启动文件允许创建默认的VM,要修改的文件位于C:\Program Files\Docker Toolbox\start.sh`,必须以管理员身份才能修改文件。
在脚本中找到以下代码:

STEP="Checking if machine $VM exists"
if [ $VM_EXISTS_CODE -eq 1 ]; then
  "${DOCKER_MACHINE}" rm -f "${VM}" &> /dev/null || :
  rm -rf ~/.docker/machine/machines/"${VM}"
  #set proxy variables if they exists
  if [ "${HTTP_PROXY}" ]; then
    PROXY_ENV="$PROXY_ENV --engine-env HTTP_PROXY=$HTTP_PROXY"
  fi
  if [ "${HTTPS_PROXY}" ]; then
    PROXY_ENV="$PROXY_ENV --engine-env HTTPS_PROXY=$HTTPS_PROXY"
  fi
  if [ "${NO_PROXY}" ]; then
    PROXY_ENV="$PROXY_ENV --engine-env NO_PROXY=$NO_PROXY"
  fi
  "${DOCKER_MACHINE}" create -d virtualbox $PROXY_ENV "${VM}"
fi

倒数第二行是创建虚拟机的地方:
"${DOCKER_MACHINE}" create -d virtualbox $PROXY_ENV "${VM}"
修改改行,加入--virtualbox-no-vtx-check,最终结果是:
"${DOCKER_MACHINE}" create -d virtualbox --virtualbox-no-vtx-check $PROXY_ENV "${VM}"
保存更改,再次运行 Docker QuickStart Terminal

问题二、如果按照上面解决方案二解决,运行Docker QuickStart Terminal依然报错,错误为下面代码。

Starting "default"...
(default) Check network to re-create if needed...
(default) Windows might ask for the permission to create a network adapter. Sometimes, such confirmation window is minimized in the taskbar.
(default) Creating a new host-only adapter produced an error: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe hostonlyif create failed:
(default) 0%...
(default) Progress state: E_INVALIDARG
(default) VBoxManage.exe: error: Failed to create the host-only adapter
(default) VBoxManage.exe: error: Assertion failed: [!aInterfaceName.isEmpty()] at 'F:\tinderbox\win-5.2\src\VBox\Main\src-server\HostNetworkInterfaceImpl.cpp' (76) in long __cdecl HostNetworkInterface::init(class com::Bstr,class com::Bstr,class com::Guid,enum __MIDL___MIDL_itf_VirtualBox_0000_0000_0038).
(default) VBoxManage.exe: error: Please contact the product vendor!
(default) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
(default) VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCreate(struct HandlerArg *)" at line 94 of file VBoxManageHostonly.cpp
(default)
(default) This is a known VirtualBox bug. Let's try to recover anyway...
(default) Found a new host-only adapter: "VirtualBox Host-Only Ethernet Adapter #5"
(default) Windows might ask for the permission to configure a network adapter. Sometimes, such confirmation window is minimized in the taskbar.
(default) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimized in the taskbar.
Unable to start the VM: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe startvm default --type headless failed:
VBoxManage.exe: error: Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_ROOT)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
 

那么,你就必须要关掉Hyper-V了,然后重启电脑。

问题三、如果之前安装,存在创建虚拟机(VM)失败的情况。此时应该在VirtulBox中删除创建过程中出错的虚拟机,重新创建虚拟机。

你可能感兴趣的:(Win10 Docker安装之坑)