Stop docker daemon, when running cri-o (#3211)

* Stop extra container runtimes, before bootstrapper

The minikube.iso starts every runtime, by default

* Disable docker-env output, if docker isn't running

Might be running an alternative container runtime
pull/3346/head
Anders Björklund 2018-11-15 01:43:07 +01:00 committed by Balint Pato
parent 2ceec0d084
commit b69fc99d62
2 changed files with 39 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import (
"text/template"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/shell"
"github.com/golang/glog"
"github.com/pkg/errors"
@ -293,6 +294,14 @@ func (EnvNoProxyGetter) GetNoProxyVar() (string, string) {
return noProxyVar, noProxyValue
}
func GetDockerActive(host *host.Host) (bool, error) {
statusCmd := `sudo systemctl is-active docker`
status, err := host.RunSSHCommand(statusCmd)
// systemd returns error code on inactive
s := strings.TrimSpace(status)
return err == nil && s == "active", err
}
// envCmd represents the docker-env command
var dockerEnvCmd = &cobra.Command{
Use: "docker-env",
@ -315,6 +324,11 @@ var dockerEnvCmd = &cobra.Command{
fmt.Println(`'none' driver does not support 'minikube docker-env' command`)
os.Exit(0)
}
docker, err := GetDockerActive(host)
if !docker {
fmt.Println(`# The docker service is currently not active`)
os.Exit(1)
}
var shellCfg *ShellConfig

View File

@ -292,6 +292,31 @@ func runStart(cmd *cobra.Command, args []string) {
cmdutil.MaybeReportErrorAndExit(err)
}
fmt.Println("Stopping extra container runtimes...")
containerRuntime := viper.GetString(containerRuntime)
if config.VMDriver != "none" && containerRuntime != "" {
if _, err := host.RunSSHCommand("sudo systemctl stop docker"); err == nil {
_, err = host.RunSSHCommand("sudo systemctl stop docker.socket")
}
if err != nil {
glog.Errorf("Error stopping docker", err)
}
}
if config.VMDriver != "none" && (containerRuntime != "crio" && containerRuntime != "cri-o") {
if _, err := host.RunSSHCommand("sudo systemctl stop crio"); err != nil {
glog.Errorf("Error stopping crio", err)
}
}
if config.VMDriver != "none" && containerRuntime != "rkt" {
if _, err := host.RunSSHCommand("sudo systemctl stop rkt-api"); err == nil {
_, err = host.RunSSHCommand("sudo systemctl stop rkt-metadata")
}
if err != nil {
glog.Errorf("Error stopping rkt", err)
}
}
fmt.Println("Starting cluster components...")
if !exists || config.VMDriver == "none" {