{"record":{"id":"c65ca220a9fc7f7b","repo":"docker/cli","slug":"no-context-specified","errorCode":null,"errorMessage":"no context specified","messagePattern":"no context specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/context/inspect.go","lineNumber":32,"sourceCode":")\n\ntype inspectOptions struct {\n\tformat string\n\trefs   []string\n}\n\n// newInspectCommand creates a new cobra.Command for `docker context inspect`\nfunc newInspectCommand(dockerCLI command.Cli) *cobra.Command {\n\tvar opts inspectOptions\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"inspect [OPTIONS] [CONTEXT] [CONTEXT...]\",\n\t\tShort: \"Display detailed information on one or more contexts\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\topts.refs = args\n\t\t\tif len(opts.refs) == 0 {\n\t\t\t\tif dockerCLI.CurrentContext() == \"\" {\n\t\t\t\t\treturn errors.New(\"no context specified\")\n\t\t\t\t}\n\t\t\t\topts.refs = []string{dockerCLI.CurrentContext()}\n\t\t\t}\n\t\t\treturn runInspect(dockerCLI, opts)\n\t\t},\n\t\tValidArgsFunction:     completeContextNames(dockerCLI, -1, false),\n\t\tDisableFlagsInUseLine: true,\n\t}\n\n\tflags := cmd.Flags()\n\tflags.StringVarP(&opts.format, \"format\", \"f\", \"\", flagsHelper.InspectFormatHelp)\n\treturn cmd\n}\n\nfunc runInspect(dockerCli command.Cli, opts inspectOptions) error {\n\tgetRefFunc := func(ref string) (any, []byte, error) {\n\t\tc, err := dockerCli.ContextStore().GetMetadata(ref)\n\t\tif err != nil {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/context/inspect.go#L14-L50","documentation":"`docker context inspect` with no positional arguments falls back to inspecting the current context. If CurrentContext() returns an empty string (no context selected via DOCKER_CONTEXT env var or config.json's currentContext), there is nothing to inspect, so it returns this error before querying the store.","triggerScenarios":"Running `docker context inspect` with no args when DOCKER_CONTEXT is unset and config.json has no currentContext field.","commonSituations":"A fresh Docker installation with no context ever selected; config.json was hand-edited or wiped; a script assumes a default context exists.","solutions":["Pass an explicit context name: `docker context inspect <name>`","Create and select a context: `docker context create <name> ...` then `docker context use <name>`","Set DOCKER_CONTEXT env var or set currentContext in ~/.docker/config.json"],"exampleFix":"// before\ndocker context inspect\n// after\ndocker context inspect default\n// or first\ndocker context use myctx && docker context inspect","handlingStrategy":"validation","validationCode":"// Ensure a context is resolvable before inspecting with no args\nif dockerCLI.CurrentContext() == \"\" {\n    // either pass an explicit name or set a context first\n    return runInspect(dockerCLI, inspectOptions{refs: []string{\"default\"}})\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass an explicit context name in automation","Run `docker context use <name>` once to set currentContext in config.json","Set DOCKER_CONTEXT in CI environment to guarantee a current context"],"tags":["context","cli","config"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}