Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Host VM re-deployed if the VM is not running. #33

Open
ray-g opened this issue Nov 30, 2016 · 5 comments
Open

Docker Host VM re-deployed if the VM is not running. #33

ray-g opened this issue Nov 30, 2016 · 5 comments
Assignees
Labels

Comments

@ray-g
Copy link

ray-g commented Nov 30, 2016

vmrun list only lists running VMs. It cannot detect if a Docker Host VM is existing but stopped.

So, if the Docker Host VM is not configured as a autostart shared VM, after a system reboot, Docker Host VM will be re-deployed.

@pecigonzalo pecigonzalo self-assigned this Nov 30, 2016
@cnliving
Copy link

cnliving commented Dec 8, 2017

Too annoying Can you start manually

@cnliving
Copy link

cnliving commented Dec 8, 2017

#!/bin/bash
#dingjianmin 2017-12-08
export PATH="$PATH:/c/Program Files/VMware14_0_0/"

trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong in step ´$STEP´... Press any key to continue..."' EXIT

VM=${DOCKER_MACHINE_NAME-default}
DOCKER_MACHINE=./docker-machine.exe
DOCKER_PATH=~/.docker/machine/machines/
BLUE='\033[1;34m'
GREEN='\033[0;32m'
NC='\033[0m'

echo "DockerVM=${VM}"
RuningVm=vmrun.exe list
echo "RuningVm=${RuningVm}"
echo "---------------------"

if [ ! -f "${DOCKER_MACHINE}" ]; then
echo "Docker Machine is not installed. Please re-run the Toolbox Installer and try again."
exit 1
fi
RuningVm=vmrun.exe list | grep "${VM}"
echo "RuningVm=${RuningVm}"
RuningVm=""
if [ "${#RuningVm} " -lt "1" ] ; then
PathVm="${DOCKER_PATH}${VM}/default.vmx"
if [ ! -f "${PathVm}" ]; then
echo "no exist ${PathVm} "
#The operation is valuable and the price of the data is higher
#"${DOCKER_MACHINE}" rm -f "${VM}" &> /dev/null || :
#rm -rf "${DOCKER_PATH}${VM}"
#set proxy variables if they exists
if [ -n ${HTTP_PROXY+x} ]; then
PROXY_ENV="$PROXY_ENV --engine-env HTTP_PROXY=$HTTP_PROXY"
fi
if [ -n ${HTTPS_PROXY+x} ]; then
PROXY_ENV="$PROXY_ENV --engine-env HTTPS_PROXY=$HTTPS_PROXY"
fi
if [ -n ${NO_PROXY+x} ]; then
PROXY_ENV="$PROXY_ENV --engine-env NO_PROXY=$NO_PROXY"
fi
"${DOCKER_MACHINE}" create -d vmwareworkstation $PROXY_ENV "${VM}"
else
echo "exist ${PathVm} "
"${DOCKER_MACHINE}" start "${VM}"
fi
else
echo "Runing ${DOCKER_PATH}${VM}"
fi

STEP="Checking status on $VM"
VM_STATUS="$(${DOCKER_MACHINE} status ${VM} 2>&1)"
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 ${VM})"

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
cd

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

@pecigonzalo
Copy link
Owner

Please use code formatting for this output

@zeronight5
Copy link

Change vmrun.exe list to "${DOCKER_MACHINE}" ls will resolve the problem.

@pecigonzalo
Copy link
Owner

Would that fix that for everyone? do you want to PR it?

@LanceaKing LanceaKing mentioned this issue Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants