docker/cli · error · notFoundErr

context %q does not exist

Error message

context %q does not exist

What it means

Error "context %q does not exist" thrown in docker/cli.

Source

Thrown at cli/command/context/remove.go:78

			return err
		}
	}

	if !force {
		// TODO(thaJeztah): instead of checking before removing, can we make ContextStore().Remove() return a proper errdef and ignore "not found" errors?
		if err := checkContextExists(dockerCli, name); err != nil {
			return err
		}
	}
	return dockerCli.ContextStore().Remove(name)
}

// checkContextExists returns an error if the context directory does not exist.
func checkContextExists(dockerCli command.Cli, name string) error {
	contextDir := dockerCli.ContextStore().GetStorageInfo(name).MetadataPath
	_, err := os.Stat(contextDir)
	if os.IsNotExist(err) {
		return notFoundErr{fmt.Errorf("context %q does not exist", name)}
	}
	// Ignore other errors; if relevant, they will produce an error when
	// performing the actual delete.
	return nil
}

type notFoundErr struct{ error }

func (notFoundErr) NotFound() {}

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/command/context/remove.go:78 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/635491a3e1c20f05.json. Report an issue: GitHub.