{"record":{"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/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/context/create.go#L70-L106","documentation":"Returned by createNewContext when opts.endpoint is nil, i.e. the user created a context without a --docker endpoint and not from an existing context. A docker context requires a docker endpoint (host + optional TLS material); without it the context is useless, so creation is aborted at create.go:87-89. The switch in runCreate only calls createNewContext in the default branch (no --from, endpoint not pre-set).","triggerScenarios":"`docker context create myctx` with no --docker and no --from. opts.endpoint stays nil and runCreate routes to createNewContext which errors.","commonSituations":"Forgetting the --docker flag on first context creation. Assuming a default host is used (it is not for explicit contexts). Misreading docs and omitting the endpoint.","solutions":["Supply --docker with at least the host: `docker context create myctx --docker host=unix:///var/run/docker.sock`.","Or base it on an existing context: `docker context create myctx --from default`.","For TLS endpoints add ca/cert/key in the --docker string."],"exampleFix":"// before\ndocker context create myctx\n\n// after\ndocker context create myctx --docker host=unix:///var/run/docker.sock","handlingStrategy":"validation","validationCode":"func validateCreate(name, from string, endpoint map[string]string) error {\n    if from == \"\" && len(endpoint) == 0 {\n        return errors.New(\"docker endpoint configuration is required\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --docker host=... when creating a fresh context.","If cloning, use --from <existing> instead.","Default the endpoint in your context-creation helper to avoid empty invocations."],"tags":["context","validation","endpoint","cli-options"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}