{"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/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/context/inspect.go#L14-L50","documentation":"`docker context inspect` with no arguments falls back to inspecting the current context (dockerCLI.CurrentContext()). If the resolved current context name is empty — no context argument, no currentContext in ~/.docker/config.json, and no DOCKER_CONTEXT — there is nothing to inspect and the command errors out rather than guessing.","triggerScenarios":"`docker context inspect` with zero arguments while dockerCLI.CurrentContext() returns \"\" (cli/command/context/inspect.go:31). Normally CurrentContext defaults to \"default\", so this surfaces when the CLI is constructed/configured such that the current context resolves to an empty string (e.g. embedded CLI usage or unusual config states).","commonSituations":"Programs embedding docker/cli that build command.DockerCli without resolving a default context; stripped/managed environments with nonstandard config files; freshly scripted environments where DOCKER_CONTEXT is set to an empty string handling.","solutions":["Name the context explicitly: `docker context inspect default` (list names with `docker context ls`).","Set a current context: `docker context use default` (or export DOCKER_CONTEXT=default).","If embedding docker/cli, ensure the CLI options resolve a current context before invoking inspect."],"exampleFix":"# before\ndocker context inspect\n# after\ndocker context inspect default","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","context","configuration"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}