Win10 Docker安裝之坑

安裝win版的docker前一定要搞清楚:Docker for windows 和 Docker Toolbox的區(qū)別。

Docker for Windows是依賴Hyper-V。

Docker ToolBox在安裝時會安裝VirtualBox,是依賴VirtualBox的。

如果你在安裝了Hyper-V的windows10上,再安裝Docker ToolBox,將可能非常慘烈。

問題一、如果已經(jīng)在windows中開啟了Hyper-V,啟動Docker QuickStart Terminal的時候就會出現(xiàn)。

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功能關(guān)閉,重啟電腦
解決方案2:
修改啟動文件允許創(chuàng)建默認(rèn)的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

倒數(shù)第二行是創(chuàng)建虛擬機(jī)的地方:
"${DOCKER_MACHINE}" create -d virtualbox $PROXY_ENV "${VM}"
修改改行,加入--virtualbox-no-vtx-check,最終結(jié)果是:
"${DOCKER_MACHINE}" create -d virtualbox --virtualbox-no-vtx-check $PROXY_ENV "${VM}"
保存更改,再次運(yùn)行 Docker QuickStart Terminal

問題二、如果按照上面解決方案二解決,運(yùn)行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
 

那么,你就必須要關(guān)掉Hyper-V了,然后重啟電腦。

問題三、如果之前安裝,存在創(chuàng)建虛擬機(jī)(VM)失敗的情況。此時應(yīng)該在VirtulBox中刪除創(chuàng)建過程中出錯的虛擬機(jī),重新創(chuàng)建虛擬機(jī)。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容