From 2574d4c0d062c6e98694649474992bc0b0400c8a Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 23 Apr 2026 14:28:16 +0200 Subject: [PATCH] rm: reject context builders before loading nodes Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- commands/rm.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/rm.go b/commands/rm.go index f14c1d2500c6..44151121bcc6 100644 --- a/commands/rm.go +++ b/commands/rm.go @@ -74,15 +74,15 @@ func runRm(ctx context.Context, dockerCli command.Cli, in rmOptions) error { return err } + if b.DockerContext { + return errors.Errorf("context builder cannot be removed, run `docker context rm %s` to remove this context", b.Name) + } + nodes, err := b.LoadNodes(timeoutCtx) if err != nil { return err } - if cb := b.ContextName(); cb != "" { - return errors.Errorf("context builder cannot be removed, run `docker context rm %s` to remove this context", cb) - } - err1 := rm(ctx, nodes, in) if err := txn.Remove(b.Name); err != nil { return err