{"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/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/stack/loader.go#L72-L108","documentation":"Emitted by `docker stack deploy` (and `docker stack config`) when no Compose file was supplied. getConfigDetails (loader.go:86-91) is called with the list of --compose-file/-c values; an empty list means the CLI has nothing to load, so it fails immediately rather than guessing a default file.","triggerScenarios":"`docker stack deploy mystack` with no -c/--compose-file flag; scripts where the variable holding the compose path expands to empty so the flag is never passed.","commonSituations":"Expecting docker-compose.yml to be picked up implicitly like `docker compose up` does — `docker stack deploy` has no default file; shell variable typos ($COMPOSE_FILE unset); migrating docker-compose commands to stack deploy without adding the flag.","solutions":["Pass the file explicitly: `docker stack deploy -c docker-compose.yml mystack`","To read from stdin, use `-c -` (e.g. `docker compose config | docker stack deploy -c - mystack`)","Multiple files can be layered with repeated -c flags: `-c base.yml -c prod.yml`"],"exampleFix":"# before\ndocker stack deploy mystack\n# specify a Compose file (with --compose-file)\n\n# after\ndocker stack deploy -c docker-compose.yml mystack","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["swarm","stack","compose","cli","flag-validation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}