我正在Ubuntu 16.04 LTS上安装Minikube(下面提供了说明)。当我手动运行每个命令时,它工作正常。但是,如果将它们放在脚本文件install.sh中,它将在最后一步失败,并给我一个错误:
错误
Starting VM...
E0710 20:42:00.618251 20443 start.go:168] Error starting host: Error getting state for host: getting connection: looking up domain: virError(Code=42, Domain=10, Message='Domain not found: no domain with matching name 'minikube'').
Retrying.
E0710 20:42:00.618595 20443 start.go:174] Error starting host: Error getting state for host: getting connection: looking up domain: virError(Code=42, Domain=10, Message='Domain not found: no domain with matching name 'minikube'')
================================================================================
An error has occurred. Would you like to opt in to sending anonymized crash
information to minikube to help prevent future errors?
To opt out of these messages, run the command:
minikube config set WantReportErrorPrompt false
================================================================================
Please enter your response [Y/n]:
说明
sudo apt-get -y update
sudo apt-get -y upgrade
#Make sure no prior copy of minikube exists.
sudo rm -rf .minikube/
#Install minikube. Make sure to check for latest version (e.g. current version is 0.28.0)
curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
#Install kvm2
curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2 && chmod +x docker-machine-driver-kvm2 && sudo mv docker-machine-driver-kvm2 /usr/bin/
sudo apt install -y libvirt-bin qemu-kvm
sudo usermod -a -G libvirtd $(whoami)
#Check to ensure libvirtd service is running.
systemctl status libvirtd
minikube start --vm-driver kvm2
此外,当脚本失败时,如果我重新运行以下命令,我将使minikube正常运行。只是不知道为什么在脚本中运行时它最初会失败。
sudo rm -rf .minikube/
minikube start --vm-driver kvm2
答案 0 :(得分:1)
如果您不是第一次运行此脚本,那么sudo rm -rf .minikube/
是不够的。
您还应该运行以下命令:
minikube delete
以防万一,在脚本顶部添加一个Shebang:
#!/bin/bash