{"record":{"id":"f2d7b7a241a5ef45","repo":"docker/cli","slug":"specify-a-compose-file-with-compose-file","errorCode":null,"errorMessage":"specify a Compose file (with --compose-file)","messagePattern":"specify a Compose file \\(with --compose-file\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/stack/loader.go","lineNumber":90,"sourceCode":"\n\treturn dicts\n}\n\nfunc propertyWarnings(properties map[string]string) string {\n\tmsgs := make([]string, 0, len(properties))\n\tfor name, description := range properties {\n\t\tmsgs = append(msgs, fmt.Sprintf(\"%s: %s\", name, description))\n\t}\n\tsort.Strings(msgs)\n\treturn strings.Join(msgs, \"\\n\\n\")\n}\n\n// getConfigDetails parse the composefiles specified in the cli and returns their ConfigDetails\nfunc getConfigDetails(composefiles []string, stdin io.Reader) (composetypes.ConfigDetails, error) {\n\tvar details composetypes.ConfigDetails\n\n\tif len(composefiles) == 0 {\n\t\treturn details, errors.New(\"specify a Compose file (with --compose-file)\")\n\t}\n\n\tif composefiles[0] == \"-\" && len(composefiles) == 1 {\n\t\tworkingDir, err := os.Getwd()\n\t\tif err != nil {\n\t\t\treturn details, err\n\t\t}\n\t\tdetails.WorkingDir = workingDir\n\t} else {\n\t\tabsPath, err := filepath.Abs(composefiles[0])\n\t\tif err != nil {\n\t\t\treturn details, err\n\t\t}\n\t\tdetails.WorkingDir = filepath.Dir(absPath)\n\t}\n\n\tvar err error\n\tdetails.ConfigFiles, err = loadConfigFiles(composefiles, stdin)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/stack/loader.go#L72-L108","documentation":"Thrown by getConfigDetails (cli/command/stack/loader.go:90) when the composefiles slice is empty. Deploying a stack requires a Compose specification to translate into swarm services/networks; with no `--compose-file` provided there is literally nothing to parse or deploy.","triggerScenarios":"Running `docker stack deploy mystack` without any `-c`/`--compose-file` argument, so `len(composefiles) == 0`.","commonSituations":"Forgot the flag interactively; a script/build step that drops `-c` due to an unset variable; expecting a default compose file that the CLI does not assume.","solutions":["Provide a Compose file: `docker stack deploy -c compose.yml mystack`.","Stream via stdin: `docker stack deploy -c - mystack < compose.yml`.","Validate that the file variable is set in scripts before invoking deploy."],"exampleFix":"// before\ndocker stack deploy mystack\n\n// after\ndocker stack deploy -c docker-compose.yml mystack\n# or from stdin:\ncat docker-compose.yml | docker stack deploy -c - mystack","handlingStrategy":"validation","validationCode":"if len(composeFiles) == 0 {\n\treturn errors.New(\"no Compose file provided; pass --compose-file / -c\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail scripts early if the compose-file variable is unset.","Default to an explicit `-c` in CI rather than relying on memory.","Validate the file exists and is readable before deploy."],"tags":["docker","stack","compose","deploy","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}