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-env: Avoid container suicide if Docker is not installed locally #8528

Merged
merged 1 commit into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions cmd/minikube/cmd/docker-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,19 @@ var dockerEnvCmd = &cobra.Command{
}
}

out, err := tryDockerConnectivity("docker", ec)
if err != nil { // docker might be up but been loaded with wrong certs/config
// to fix issues like this #8185
glog.Warningf("couldn't connect to docker inside minikube. will try to restart dockerd service... output: %s error: %v", string(out), err)
mustRestartDocker(cname, co.CP.Runner)
dockerPath, err := exec.LookPath("docker")
if err != nil {
glog.Warningf("Unable to find docker in path - skipping connectivity check: %v", err)
dockerPath = ""
}

if dockerPath != "" {
out, err := tryDockerConnectivity("docker", ec)
if err != nil { // docker might be up but been loaded with wrong certs/config
// to fix issues like this #8185
glog.Warningf("couldn't connect to docker inside minikube. will try to restart dockerd service... output: %s error: %v", string(out), err)
mustRestartDocker(cname, co.CP.Runner)
}
}

if dockerUnset {
Expand Down Expand Up @@ -268,6 +276,7 @@ func dockerEnvVarsList(ec DockerEnvConfig) []string {
func tryDockerConnectivity(bin string, ec DockerEnvConfig) ([]byte, error) {
c := exec.Command(bin, "version", "--format={{.Server}}")
c.Env = append(os.Environ(), dockerEnvVarsList(ec)...)
glog.Infof("Testing Docker connectivity with: %v", c)
return c.CombinedOutput()
}

Expand Down