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. 虚拟机

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

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

此时,通过双击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是从哪里创建的快捷方式,右键->属性

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

三、其他

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

 #!/bin/bash
trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong in step ´$STEP´... Press any key to continue..."' EXIT #Quick Hack: used to convert e.g. "C:\Program Files\Docker Toolbox" to "/c/Program Files/Docker Toolbox"
win_to_unix_path(){
wd="$(pwd)"
cd "$1"
the_path="$(pwd)"
cd "$wd"
echo $the_path
} # This is needed to ensure that binaries provided
# by Docker Toolbox over-ride binaries provided by
# Docker for Windows when launching using the Quickstart.
export PATH="D:\usr\Docker Toolbox:$PATH"
VM=${DOCKER_MACHINE_NAME-default}
DOCKER_MACHINE="D:\usr\Docker Toolbox\docker-machine.exe" STEP="Looking for vboxmanage.exe"
if [ ! -z "$VBOX_MSI_INSTALL_PATH" ]; then
VBOXMANAGE="${VBOX_MSI_INSTALL_PATH}VBoxManage.exe"
else
VBOXMANAGE="${VBOX_INSTALL_PATH}VBoxManage.exe"
fi BLUE='\033[1;34m'
GREEN='\033[0;32m'
NC='\033[0m' #clear all_proxy if not socks address
if [[ $ALL_PROXY != socks* ]]; then
unset ALL_PROXY
fi
if [[ $all_proxy != socks* ]]; then
unset all_proxy
fi if [ ! -f "${DOCKER_MACHINE}" ]; then
echo "Docker Machine is not installed. Please re-run the Toolbox Installer and try again."
exit
fi if [ ! -f "${VBOXMANAGE}" ]; then
echo "VirtualBox is not installed. Please re-run the Toolbox Installer and try again."
exit
fi "${VBOXMANAGE}" list vms | grep \""${VM}"\" &> /dev/null
VM_EXISTS_CODE=$? set -e STEP="Checking if machine $VM exists"
if [ $VM_EXISTS_CODE -eq ]; 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 STEP="Checking status on $VM"
VM_STATUS="$( set +e ; "${DOCKER_MACHINE}" status "${VM}" )"
if [ "${VM_STATUS}" != "Running" ]; then
"${DOCKER_MACHINE}" start "${VM}"
yes | "${DOCKER_MACHINE}" regenerate-certs "${VM}"
fi STEP="Setting env"
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
eval "$("${DOCKER_MACHINE}" env --shell=bash --no-proxy "${VM}")" #for transient Environment Variables, available in current session STEP="Finalize"
clear
cat << EOF ## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/ EOF
echo -e "${BLUE}docker${NC} is configured to use the ${GREEN}${VM}${NC} machine with IP ${GREEN}$("${DOCKER_MACHINE}" ip ${VM})${NC}"
echo "For help getting started, check out the docs at https://docs.docker.com"
echo
echo
#cd #Bad: working dir should be whatever directory was invoked from rather than fixed to the Home folder docker () {
MSYS_NO_PATHCONV= docker.exe "$@"
}
export -f docker if [ $# -eq ]; then
echo "Start interactive shell"
exec "$BASH" --login -i
else
echo "Start shell with command"
exec "$BASH" -c "$*"
fi
上一篇:用ECMAScript4 ( ActionScript3) 实现Unity的热更新 -- 使用FairyGUI (一)


下一篇:linux 下部署web 程序