{"id":"9e8b855debba4976","repo":"docker/cli","slug":"docker-endpoint-configuration-is-required","errorCode":null,"errorMessage":"docker endpoint configuration is required","messagePattern":"docker endpoint configuration is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/context/create.go","lineNumber":88,"sourceCode":"\t}\n\tswitch {\n\tcase opts.from == \"\" && opts.endpoint == nil:\n\t\terr = createFromExistingContext(s, name, dockerCLI.CurrentContext(), opts)\n\tcase opts.from != \"\":\n\t\terr = createFromExistingContext(s, name, opts.from, opts)\n\tdefault:\n\t\terr = createNewContext(s, name, opts)\n\t}\n\tif err == nil {\n\t\t_, _ = fmt.Fprintln(dockerCLI.Out(), name)\n\t\t_, _ = fmt.Fprintf(dockerCLI.Err(), \"Successfully created context %q\\n\", name)\n\t}\n\treturn err\n}\n\nfunc createNewContext(contextStore store.ReaderWriter, name string, opts createOptions) error {\n\tif opts.endpoint == nil {\n\t\treturn errors.New(\"docker endpoint configuration is required\")\n\t}\n\tdockerEP, dockerTLS, err := getDockerEndpointMetadataAndTLS(contextStore, opts.endpoint)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to create docker endpoint config: %w\", err)\n\t}\n\tcontextMetadata := store.Metadata{\n\t\tEndpoints: map[string]any{\n\t\t\tdocker.DockerEndpoint: dockerEP,\n\t\t},\n\t\tMetadata: command.DockerContext{\n\t\t\tDescription:      opts.description,\n\t\t\tAdditionalFields: opts.metaData,\n\t\t},\n\t\tName: name,\n\t}\n\tcontextTLSData := store.ContextTLSData{}\n\tif dockerTLS != nil {\n\t\tcontextTLSData.Endpoints = map[string]store.EndpointTLSData{","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/context/create.go#L70-L106","documentation":"createNewContext requires a docker endpoint configuration (opts.endpoint) before it will build the context's endpoint metadata. In current code the no-endpoint/no-from case is routed to copying the current context, so this guard fires when creation reaches createNewContext with an empty --docker spec — a context without a docker endpoint would be unusable.","triggerScenarios":"`docker context create <name>` paths that reach createNewContext (cli/command/context/create.go:86) with opts.endpoint == nil — e.g. flag parsing produced an empty endpoint map, or programmatic callers invoking createNewContext directly without endpoint config.","commonSituations":"Scripts building the --docker argument from an empty variable (`--docker \"$OPTS\"` with OPTS unset can yield an empty spec); older docker CLI versions where omitting both --docker and --from was an error instead of copying the current context; library consumers calling the create path with incomplete options.","solutions":["Provide an endpoint: `docker context create mycontext --docker \"host=ssh://user@host\"` (or host=tcp://... / unix://...).","To duplicate an existing context instead, use `--from <context>` or omit both flags on a recent CLI (copies the current context).","In scripts, validate the endpoint variable is non-empty before passing --docker."],"exampleFix":"# before\ndocker context create remote\n# (older CLI: docker endpoint configuration is required)\n# after\ndocker context create remote --docker \"host=ssh://deploy@prod-server\"","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","context","configuration","endpoint"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}