docker/cli · error
source is required
Error message
source is required
What it means
Thrown by ConfigOpt.Set when parsing a --config request in key=value form but no source/src key was provided. A Swarm config reference requires a source config name to mount; the parser only validates this after consuming all fields, so a missing source is caught at the end. The simple short form (--config foo) auto-sets source and never triggers this.
Solutions
- Add source=<configname> (or src=) to the --config spec.
- Use the short form --config <configname> if no other overrides are needed.
- Verify the config exists with docker config ls before referencing it.
Example fix
// before --config target=/app.conf,uid=33 // after --config source=appcfg,target=/app.conf,uid=33
Defensive patterns
Strategy: validation
Validate before calling
hasSource := false
for _, f := range strings.Split(spec, ",") {
k, _, _ := strings.Cut(strings.ToLower(f), "=")
if k == "source" || k == "src" {
hasSource = true
}
}
if !hasSource && !(len(strings.Split(spec, ",")) == 1 && !strings.Contains(spec, "=")) {
return errors.New("config spec requires source=")
} Try / catch
if err := configOpt.Set(spec); err != nil {
return err
} Prevention
- Default to the short form --config <name> when no overrides are needed.
- Always include source= in key=value config specs.
When it happens
Trigger: Passing --config target=/app.conf without a source=, or any key=value config spec omitting source/src.
Common situations: Mistakenly believing target alone identifies the config, or copy-pasting a partial spec that lost the source field.
Related errors
- error reading from STDIN: data is empty
- config file is required
- cannot supply extra formatting options to the pretty…
- hostip is not supported
- invalid field in secret request
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/b50c47268cb1585d.
Report an issue: GitHub.
Appendix: source
Thrown at opts/swarmopts/config.go:72
options.File.Name = val
case "uid":
options.File.UID = val
case "gid":
options.File.GID = val
case "mode":
m, err := strconv.ParseUint(val, 0, 32)
if err != nil {
return fmt.Errorf("invalid mode specified: %v", err)
}
options.File.Mode = os.FileMode(m)
default:
return fmt.Errorf("invalid field in config request: %s", key)
}
}
if options.ConfigName == "" {
return errors.New("source is required")
}
if options.File.Name == "" {
options.File.Name = options.ConfigName
}
o.values = append(o.values, options)
return nil
}
// Type returns the type of this option
func (*ConfigOpt) Type() string {
return "config"
}
// String returns a string repr of this option
func (o *ConfigOpt) String() string {
configs := make([]string, 0, len(o.values))
for _, config := range o.values {View on GitHub (pinned to 4f84911bfe)