From e8585b708d291e1a125d4cc1808681bf18b2ca92 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 22 Apr 2019 14:25:57 -0700 Subject: [PATCH] commands: check current context when switching to default Signed-off-by: Tonis Tiigi --- commands/use.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commands/use.go b/commands/use.go index 9b55a2ac..e3c2134f 100644 --- a/commands/use.go +++ b/commands/use.go @@ -23,6 +23,9 @@ func runUse(dockerCli command.Cli, in useOptions, name string) error { if _, err := txn.NodeGroupByName(name); err != nil { if os.IsNotExist(errors.Cause(err)) { + if name == "default" && name != dockerCli.CurrentContext() { + return errors.Errorf("run `docker context use default` to switch to default context") + } if name == "default" || name == dockerCli.CurrentContext() { ep, err := getCurrentEndpoint(dockerCli) if err != nil {