diff --git a/commands.go b/commands.go index 4909f7e5..63ea0f19 100644 --- a/commands.go +++ b/commands.go @@ -760,6 +760,10 @@ func cmdSsh(c *cli.Context) { log.Fatalf("unable to get active host: %v", err) } + if host == nil { + log.Fatalf("There is no active host. Please set it with %s active .", c.App.Name) + } + name = host.Name } @@ -768,6 +772,15 @@ func cmdSsh(c *cli.Context) { log.Fatal(err) } + _, err = host.GetURL() + if err != nil { + if err == drivers.ErrHostIsNotRunning { + log.Fatalf("%s is not running. Please start this with docker-machine start %s", host.Name, host.Name) + } else { + log.Fatalf("Unexpected error getting machine url: %s", err) + } + } + if len(c.Args()) <= 1 { sshCmd, err = host.GetSSHCommand() } else { @@ -880,6 +893,9 @@ func runActionWithContext(actionName string, c *cli.Context) error { if err != nil { log.Fatalf("Unable to get active host: %v", err) } + if activeHost == nil { + log.Fatalf("There is no active host. Please set it with %s active .", c.App.Name) + } machines = []*libmachine.Host{activeHost} }