{"id":"71d83c08acebe1a7","repo":"docker/cli","slug":"config-file-is-required","errorCode":null,"errorMessage":"config file is required","messagePattern":"config file is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/config/create.go","lineNumber":122,"sourceCode":"\n// readConfigData reads the config from either stdin or the given fileName.\n//\n// It reads up to twice the maximum size of the config ([maxConfigSize]),\n// just in case swarm's limit changes; this is only a safeguard to prevent\n// reading arbitrary files into memory.\nfunc readConfigData(in io.Reader, fileName string) ([]byte, error) {\n\tswitch fileName {\n\tcase \"-\":\n\t\tdata, err := io.ReadAll(io.LimitReader(in, 2*maxConfigSize))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading from STDIN: %w\", err)\n\t\t}\n\t\tif len(data) == 0 {\n\t\t\treturn nil, errors.New(\"error reading from STDIN: data is empty\")\n\t\t}\n\t\treturn data, nil\n\tcase \"\":\n\t\treturn nil, errors.New(\"config file is required\")\n\tdefault:\n\t\t// Open file with [FILE_FLAG_SEQUENTIAL_SCAN] on Windows, which\n\t\t// prevents Windows from aggressively caching it. We expect this\n\t\t// file to be only read once. Given that this is expected to be\n\t\t// a small file, this may not be a significant optimization, so\n\t\t// we could choose to omit this, and use a regular [os.Open].\n\t\t//\n\t\t// [FILE_FLAG_SEQUENTIAL_SCAN]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN\n\t\tf, err := sequential.Open(fileName)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading from %s: %w\", fileName, err)\n\t\t}\n\t\tdefer f.Close()\n\t\tdata, err := io.ReadAll(io.LimitReader(f, 2*maxConfigSize))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading from %s: %w\", fileName, err)\n\t\t}\n\t\tif len(data) == 0 {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/config/create.go#L104-L140","documentation":"Raised by readConfigData in cli/command/config/create.go when the file argument for `docker config create` is an empty string. The command needs either a real file path or \"-\" for stdin; an empty name means there is no source for the config data at all, so it fails before touching the filesystem.","triggerScenarios":"Invoking the config-create code path with fileName == \"\" — on the CLI this means the file argument was supplied as an empty string (e.g. an unset shell variable: `docker config create myconfig \"$CONFIG_FILE\"`), or a programmatic caller of RunConfigCreate passed empty options.File.","commonSituations":"Shell scripts where the config-file variable is undefined or emptied by a failed earlier step; templated CI jobs where the parameter wasn't substituted; Go code driving the config create logic with a zero-value options struct.","solutions":["Make sure the file argument expands to a real path — quote and validate it: `: \"${CONFIG_FILE:?must be set}\"` before the docker call.","Use `-` explicitly if you intend to read from stdin: `docker config create myconfig -`.","For programmatic callers, populate options.File (path or \"-\") before calling RunConfigCreate."],"exampleFix":"# before\ndocker config create app-config \"$CONFIG_FILE\"   # CONFIG_FILE unset -> \"\"\n# after\n: \"${CONFIG_FILE:?CONFIG_FILE must point to the config file}\"\ndocker config create app-config \"$CONFIG_FILE\"","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","swarm-config","shell-scripting","validation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}