Skip to content

Commit

Permalink
Stop docker daemon, when running cri-o (#3211)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
afbjorklund authored and balopat committed Nov 15, 2018
1 parent 2ceec0d commit b69fc99
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/minikube/cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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

Expand Down
25 changes: 25 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit b69fc99

Please sign in to comment.