{"record":{"id":"a5e329a50ac082a6","repo":"docker/compose","slug":"building-from-stdin-is-not-supported","errorCode":null,"errorMessage":"building from STDIN is not supported","messagePattern":"building from STDIN is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/compose/build_classic.go","lineNumber":166,"sourceCode":"\n\tif service.Build.Labels == nil {\n\t\tservice.Build.Labels = make(map[string]string)\n\t}\n\tservice.Build.Labels[api.ImageBuilderLabel] = \"classic\"\n\n\tdockerfileName := dockerFilePath(service.Build.Context, service.Build.Dockerfile)\n\tspecifiedContext := service.Build.Context\n\tprogBuff := s.stdout()\n\tbuildBuff := s.stdout()\n\n\tcontextType, err := build.DetectContextType(specifiedContext)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tswitch contextType {\n\tcase build.ContextTypeStdin:\n\t\treturn \"\", fmt.Errorf(\"building from STDIN is not supported\")\n\tcase build.ContextTypeLocal:\n\t\tcontextDir, relDockerfile, err = build.GetContextFromLocalDir(specifiedContext, dockerfileName)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to prepare context: %w\", err)\n\t\t}\n\t\tif strings.HasPrefix(relDockerfile, \"..\"+string(filepath.Separator)) {\n\t\t\t// Dockerfile is outside build-context; read the Dockerfile and pass it as dockerfileCtx\n\t\t\tdockerfileCtx, err = os.Open(dockerfileName)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"unable to open Dockerfile: %w\", err)\n\t\t\t}\n\t\t\tdefer dockerfileCtx.Close() //nolint:errcheck\n\t\t}\n\tcase build.ContextTypeGit:\n\t\tvar tempDir string\n\t\ttempDir, relDockerfile, err = build.GetContextFromGitURL(specifiedContext, dockerfileName)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to prepare context: %w\", err)","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/compose/build_classic.go#L148-L184","documentation":"doBuildClassic calls build.DetectContextType on the resolved build context; when the context string is `-` (ContextTypeStdin) the classic builder cannot proceed because this code path builds a tar archive from a directory and has no way to consume a Dockerfile/context piped on stdin. Only BuildKit supports stdin contexts (it base64-encodes the Dockerfile into the API request).","triggerScenarios":"A Compose file (or interpolated value) that sets the service build context to `-`, e.g. `context: -`, combined with the classic builder path; commonly from `docker compose build -f-` style stdin usage or templated context fields resolving to '-'.","commonSituations":"Piping generated Compose files via stdin with env interpolation making the context '-'; scripts that reuse `docker build -` idioms inside Compose; YAML interpolation bugs where a variable holding the context is empty and a fallback '-' is used.","solutions":["Set DOCKER_BUILDKIT=1 so the BuildKit path handles stdin contexts","Prefer a concrete context directory in the Compose file (e.g. `context: .`) instead of '-'","Check the interpolated value of the context variable — an empty var defaulting to '-' is usually a configuration mistake"],"exampleFix":"# before\nservices:\n  app:\n    build:\n      context: \"${BUILD_CONTEXT:--}\"\n\n# after\nservices:\n  app:\n    build:\n      context: \"${BUILD_CONTEXT:-.}\"","handlingStrategy":"validation","validationCode":"ctx := strings.TrimSpace(svc.Build.Context)\nif ctx == \"-\" {\n    return fmt.Errorf(\"service %s: stdin context requires DOCKER_BUILDKIT=1\", svc.Name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid '-' as a context in Compose files; use a real directory","Set a safe interpolation default like ${BUILD_CONTEXT:-.} instead of ${BUILD_CONTEXT:--}"],"tags":["build","stdin","context","classic-builder"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}