windows7安装docker异常:looks like something went wrong in step ‘looking for vboxmanage.exe’

一、背景

最近准备抽点时间研究下docker,选择在家中的windows系统上安装。

我的系统是windows7,首先安装Docker Toolbox,Docker Toolbox是一个工具集,主要包含如下内容:

Docker CLI 客户端,用来运行docker引擎创建镜像和容器
Docker Machine. 可以让你在windows的命令行中运行docker引擎命令
Docker Compose. 用来运行docker-compose命令
Kitematic. 这是Docker的GUI版本
Docker QuickStart shell. 这是一个已经配置好Docker的命令行环境
Oracle VM Virtualbox. 虚拟机

安装完之后,桌面得到如下内容:

此时,通过双击Docker Quickstart Termimal启动。

二、问题

1、问题:looks like something went wrong in step ‘looking for vboxmanage.exe’

一切进行顺利,直到。。。在终端出现如下异常:looks like something went wrong in step ‘looking for vboxmanage.exe’

常规心态:一般出现这种找不到文件的异常都是因为安装目录有问题导致,所以首先看下Docker Quickstart Termimal是从哪里创建的快捷方式,右键->属性

紧跟路径,打开脚本文件start.sh,发现了异常提示是出现在地20行,如下所示:

 直观感觉就是由于变量“${VBOX_MSI_INSTALL_PATH}”,或者变量“${VBOX_INSTALL_PATH}”获取异常导致,首先查看环境变量,是否该变量没有写入

发现一切正常,那就通过打印这个变量的值来验证下这个想法,使用最暴力直接的方法,输出变量“${VBOX_MSI_INSTALL_PATH}”,为了防止脚本继续执行,通过read断点

再次运行Docker Quickstart Termimal,结果如下:

发现变量正常解析,那么问题可能不在这里,继续向下断点排查,直到这里

问题直接指向变量"${DOCKER_MACHINE}"获取异常,而该变量是在脚本第18行定义:DOCKER_MACHINE="${DOCKER_TOOLBOX_INSTALL_PATH}\docker-machine.exe",使用相同的方法,输出变量${DOCKER_TOOLBOX_INSTALL_PATH}

很明显,该变量获取为空,我的docker-machine.exe是安装在“D:\usr\Docker Toolbox\”,所以直接修改脚本:

同样,将脚本中该变量全部替换为具体路径,再次运行Docker Quickstart Termimal,问题解决,其他一切顺利!

三、其他

附上我个人使用的脚本代码,替换掉响应路径即可

  1 #!/bin/bash
  2 trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong in step ´$STEP´... Press any key to continue..."' EXIT
  3 
  4 #Quick Hack: used to convert e.g. "C:\Program Files\Docker Toolbox" to "/c/Program Files/Docker Toolbox"
  5 win_to_unix_path(){ 
  6   wd="$(pwd)"
  7   cd "$1"
  8     the_path="$(pwd)"
  9   cd "$wd"
 10   echo $the_path
 11 }
 12 
 13 # This is needed  to ensure that binaries provided
 14 # by Docker Toolbox over-ride binaries provided by
 15 # Docker for Windows when launching using the Quickstart.
 16 export PATH="D:\usr\Docker Toolbox:$PATH"
 17 VM=${DOCKER_MACHINE_NAME-default}
 18 DOCKER_MACHINE="D:\usr\Docker Toolbox\docker-machine.exe"
 19 
 20 STEP="Looking for vboxmanage.exe"
 21 if [ ! -z "$VBOX_MSI_INSTALL_PATH" ]; then
 22   VBOXMANAGE="${VBOX_MSI_INSTALL_PATH}VBoxManage.exe"
 23 else
 24   VBOXMANAGE="${VBOX_INSTALL_PATH}VBoxManage.exe"
 25 fi
 26 
 27 BLUE='\033[1;34m'
 28 GREEN='\033[0;32m'
 29 NC='\033[0m'
 30 
 31 #clear all_proxy if not socks address
 32 if  [[ $ALL_PROXY != socks* ]]; then
 33   unset ALL_PROXY
 34 fi
 35 if  [[ $all_proxy != socks* ]]; then
 36   unset all_proxy
 37 fi
 38 
 39 if [ ! -f "${DOCKER_MACHINE}" ]; then
 40   echo "Docker Machine is not installed. Please re-run the Toolbox Installer and try again."
 41   exit 1
 42 fi
 43 
 44 if [ ! -f "${VBOXMANAGE}" ]; then
 45   echo "VirtualBox is not installed. Please re-run the Toolbox Installer and try again."
 46   exit 1
 47 fi
 48 
 49 "${VBOXMANAGE}" list vms | grep \""${VM}"\" &> /dev/null
 50 VM_EXISTS_CODE=$?
 51 
 52 set -e
 53 
 54 STEP="Checking if machine $VM exists"
 55 if [ $VM_EXISTS_CODE -eq 1 ]; then
 56   "${DOCKER_MACHINE}" rm -f "${VM}" &> /dev/null || :
 57   rm -rf ~/.docker/machine/machines/"${VM}"
 58   #set proxy variables if they exists
 59   if [ "${HTTP_PROXY}" ]; then
 60     PROXY_ENV="$PROXY_ENV --engine-env HTTP_PROXY=$HTTP_PROXY"
 61   fi
 62   if [ "${HTTPS_PROXY}" ]; then
 63     PROXY_ENV="$PROXY_ENV --engine-env HTTPS_PROXY=$HTTPS_PROXY"
 64   fi
 65   if [ "${NO_PROXY}" ]; then
 66     PROXY_ENV="$PROXY_ENV --engine-env NO_PROXY=$NO_PROXY"
 67   fi
 68   "${DOCKER_MACHINE}" create -d virtualbox $PROXY_ENV "${VM}"
 69 fi
 70 
 71 STEP="Checking status on $VM"
 72 VM_STATUS="$( set +e ; "${DOCKER_MACHINE}" status "${VM}" )"
 73 if [ "${VM_STATUS}" != "Running" ]; then
 74   "${DOCKER_MACHINE}" start "${VM}"
 75   yes | "${DOCKER_MACHINE}" regenerate-certs "${VM}"
 76 fi
 77 
 78 STEP="Setting env"
 79 eval "$("${DOCKER_MACHINE}" env --shell=bash --no-proxy "${VM}" | sed -e "s/export/SETX/g" | sed -e "s/=/ /g")" &> /dev/null #for persistent Environment Variables, available in next sessions
 80 eval "$("${DOCKER_MACHINE}" env --shell=bash --no-proxy "${VM}")" #for transient Environment Variables, available in current session
 81 
 82 STEP="Finalize"
 83 clear
 84 cat << EOF
 85 
 86 
 87                         ##         .
 88                   ## ## ##        ==
 89                ## ## ## ## ##    ===
 90            /"""""""""""""""""\___/ ===
 91       ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
 92            \______ o           __/
 93              \    \         __/
 94               \____\_______/
 95 
 96 EOF
 97 echo -e "${BLUE}docker${NC} is configured to use the ${GREEN}${VM}${NC} machine with IP ${GREEN}$("${DOCKER_MACHINE}" ip ${VM})${NC}"
 98 echo "For help getting started, check out the docs at https://docs.docker.com"
 99 echo
100 echo 
101 #cd #Bad: working dir should be whatever directory was invoked from rather than fixed to the Home folder
102 
103 docker () {
104   MSYS_NO_PATHCONV=1 docker.exe "$@"
105 }
106 export -f docker
107 
108 if [ $# -eq 0 ]; then
109   echo "Start interactive shell"
110   exec "$BASH" --login -i
111 else
112   echo "Start shell with command"
113   exec "$BASH" -c "$*"
114 fi
View Code
posted @ 2018-11-25 22:55  杰哥妥妥的  阅读(16611)  评论(4编辑  收藏  举报