From e8585b708d291e1a125d4cc1808681bf18b2ca92 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 22 Apr 2019 14:25:57 -0700 Subject: [PATCH 1/2] 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 { From bca7bf28f93190b190935f8d0308e27a988619cb Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 22 Apr 2019 14:26:18 -0700 Subject: [PATCH 2/2] commands: avoid creating instance from tls environment Signed-off-by: Tonis Tiigi --- commands/create.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/commands/create.go b/commands/create.go index 657d6618..49d5ce38 100644 --- a/commands/create.go +++ b/commands/create.go @@ -119,6 +119,10 @@ func runCreate(dockerCli command.Cli, in createOptions, args []string) error { return err } } else { + if dockerCli.CurrentContext() == "default" && dockerCli.DockerEndpoint().TLSData != nil { + return errors.Errorf("could not create a builder instance with TLS data loaded from environment. Please use `docker context create ` to create a context for current environment and then create a builder instance with `docker buildx create `") + } + ep, err = getCurrentEndpoint(dockerCli) if err != nil { return err