docker-archive / toolbox

The Docker Toolbox
https://docker.com/toolbox
3.22k stars 1.23k forks source link

Should be able to install on Windows without VirtualBox #463

Open SebTardif opened 8 years ago

SebTardif commented 8 years ago

I already have VMWare Workstation, and I still need some features provided by Toolbox but it's not possible to install Toolbox without VirtualBox.

It's easy to install Docker with VMWare Workstation driver support using Chocolatey: https://stefanscherer.github.io/get-started-with-docker-on-windows-using-chocolatey/

However, finding a bash shell that work without the "cannot enable tty mode" error is hard: https://github.com/docker/toolbox/issues/136

For example, msys's bash still has the problem.

But the "Docker Quickstart Terminal" provided by Toolbox works fine with VMWare Workstation driver without the tty problem.

So...it would be nice to have a clean path for a new installation to use Docker on Windows with VMWare Workstation, without installing VirtualBox and other extra.

putztzu commented 8 years ago

See my comment to issue https://github.com/docker/toolbox/issues/191 IMO this should best be addressed by re-evaluating the install and running architecture, creating a more modular architecture which disconnects Toolbox configurations and instead modifies and stores component configurations (like the Virtualization used) in the component only.

jonstelly commented 8 years ago

At the very least, the readme.md needs to be updated until this is resolved, it's really misleading/confusing seeing a FAQ entry that says:

Do I have to install VirtualBox? No, you can deselect VirtualBox during installation. It is bundled in case you want to have a working environment for free.

When that's not the case.

dubrowgn commented 8 years ago

On Windows you can't run VirtualBox alongside Hyper-V (with acceleration enabled anyway). Installing VirtualBox when you already have Hyper-V running is about as pointless as you can get, so being able to deselect VirtualBox during instillation would be awesome (again, as it appears to have been possible in the past).

siennathesane commented 8 years ago

I agree with @SebTardif and @dubrowgn. You cannot run both and not being able to deselect Virtualbox is a blocker for using the Toolbox, when the only other installation method is Chocolately. I'm willing to work on getting a PR started if someone can point out a good starting place.

nimerix commented 8 years ago

The ability to toggle Git and Virtualbox was removed in https://github.com/docker/toolbox/commit/0be4f32a696854b7acc5ccc296e050858e2f1585. While the components are not fixed, they are necessary for out of the box functionality. With that in mind, it's completely possible to run the installer in a modular fashion via the /COMPONENTS parameter:

# Docker and DockerMachine are required. 
$ DockerToolbox-<version>.exe /COMPONENTS="Docker,DockerMachine"
gtirloni commented 8 years ago

While it's possible to install Docker Toolbox without VirtualBox following the /COMPONENTS method, the Docker terminal fails to start with the following message:

Looks like something went wrong in step ´Looking for vboxmanage.exe´...

Kitematic's first run will report:

Error: getaddrinfo ENOTFOUND docker.local docker.local:2375

I have VMware Workstation 12.1 running on Windows 10 here.

nesl247 commented 7 years ago

Any update on this? Seems kinda crazy this is still going on.

Arnavion commented 7 years ago

For anyone looking to make the "Docker Quickstart Terminal" work with Hyper-V after using the /COMPONENTS method above, apply this diff to C:\Program Files\Docker Toolbox\start.sh

--- "/c/Program Files/Docker Toolbox/start.sh.orig"  2017-08-30 18:41:12.000000000 -0700
+++ "/c/Program Files/Docker Toolbox/start.sh"   2017-10-09 16:34:30.510008600 -0700
@@ -9,13 +9,6 @@ export PATH="/c/Program Files/Docker Too
 VM=${DOCKER_MACHINE_NAME-default}
 DOCKER_MACHINE=./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'
@@ -33,12 +26,7 @@ if [ ! -f "${DOCKER_MACHINE}" ]; then
   exit 1
 fi

-if [ ! -f "${VBOXMANAGE}" ]; then
-  echo "VirtualBox is not installed. Please re-run the Toolbox Installer and try again."
-  exit 1
-fi
-
-"${VBOXMANAGE}" list vms | grep \""${VM}"\" &> /dev/null
+powershell -NoProfile -Command "Get-VM '${VM}'" &> /dev/null
 VM_EXISTS_CODE=$?

 set -e
@@ -57,7 +45,7 @@ if [ $VM_EXISTS_CODE -eq 1 ]; then
   if [ "${NO_PROXY}" ]; then
     PROXY_ENV="$PROXY_ENV --engine-env NO_PROXY=$NO_PROXY"
   fi
-  "${DOCKER_MACHINE}" create -d virtualbox $PROXY_ENV "${VM}"
+  "${DOCKER_MACHINE}" create -d hyperv $PROXY_ENV "${VM}"
 fi

 STEP="Checking status on $VM"

For other drivers like VMWare, the last two changes (the part that looks for the existing VM and the part that calls docker-machine create need to be modified accordingly.

quycao commented 4 years ago

For anyone looking to make the "Docker Quickstart Terminal" work with Hyper-V after using the /COMPONENTS method above, apply this diff to C:\Program Files\Docker Toolbox\start.sh For other drivers like VMWare, the last two changes (the part that looks for the existing VM and the part that calls docker-machine create need to be modified accordingly.

Thank you! Base on @Arnavion's code, I modify the start.sh to use with QEMU driver at https://github.com/quycao/docker-machine-driver-qemu

#!/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="$(win_to_unix_path "${DOCKER_TOOLBOX_INSTALL_PATH}"):$PATH"
VM=${DOCKER_MACHINE_NAME-default}
DOCKER_MACHINE="${DOCKER_TOOLBOX_INSTALL_PATH}\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 1
fi

# if [ ! -f "${VBOXMANAGE}" ]; then
#   echo "VirtualBox is not installed. Please re-run the Toolbox Installer and try again."
#   exit 1
# fi

# "${VBOXMANAGE}" list vms | grep \""${VM}"\" &> /dev/null
powershell -NoProfile -Command "Get-WmiObject Win32_Process -Filter \"name = 'qemu-system-x86_64.exe'\" | Select-Object CommandLine | Select-String \"${VM}\"" &> /dev/null
VM_EXISTS_CODE=$?

set -e

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 inside virtual docker machine if they exist in host environment
  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}"
  "${DOCKER_MACHINE}" create -d qemu $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=1 docker.exe "$@"
}
export -f docker

if [ $# -eq 0 ]; then
  echo "Start interactive shell"
  exec "$BASH" --login -i
else
  echo "Start shell with command"
  exec "$BASH" -c "$*"
fi