commands: check current context when switching to default

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2019-04-22 14:25:57 -07:00
parent e94d215291
commit e8585b708d

View File

@ -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 {