From 6276c1cb1da7529b1f8fad712f6f9b7be56a7a72 Mon Sep 17 00:00:00 2001 From: tstromberg Date: Thu, 2 Apr 2020 12:33:13 -0700 Subject: [PATCH] none: check for docker and root --- pkg/minikube/registry/drvs/none/none.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/registry/drvs/none/none.go b/pkg/minikube/registry/drvs/none/none.go index 26542d4d2831..15dddd3a8b0a 100644 --- a/pkg/minikube/registry/drvs/none/none.go +++ b/pkg/minikube/registry/drvs/none/none.go @@ -21,6 +21,7 @@ package none import ( "fmt" "os/exec" + "os/user" "github.com/docker/machine/libmachine/drivers" "k8s.io/minikube/pkg/drivers/none" @@ -51,9 +52,22 @@ func configure(cc config.ClusterConfig, n config.Node) (interface{}, error) { } func status() registry.State { - _, err := exec.LookPath("systemctl") - if err != nil { + if _, err := exec.LookPath("systemctl"); err != nil { return registry.State{Error: err, Fix: "Use a systemd based Linux distribution", Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/none/"} } + + if _, err := exec.LookPath("docker"); err != nil { + return registry.State{Error: err, Installed: false, Fix: "Install docker", Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/none/"} + } + + u, err := user.Current() + if err != nil { + return registry.State{Error: err, Healthy: false, Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/none/"} + } + + if u.Uid != "0" { + return registry.State{Error: fmt.Errorf("The 'none' driver must be run as the root user"), Healthy: false, Fix: "For non-root usage, try the newer 'docker' driver", Installed: true} + } + return registry.State{Installed: true, Healthy: true} }