docker/cli · error

parsing config file ( )

Error message

parsing config file (%s): %w

What it means

Returned by `load` (config.go:148-150) when the config file was opened successfully but ConfigFile.LoadFromReader failed to JSON-decode it. The filename is interpolated. LoadFromReader decodes into the ConfigFile struct and also base64-decodes each `auths[].auth`; any JSON syntax error or base64/decode error surfaces here.

Solutions

  1. Validate the JSON: `python -m json.tool ~/.docker/config.json` or `cat` it and look for syntax errors.
  2. If the error mentions decoding auth, inspect each `auths` entry and ensure `auth` is base64 of `username:password`.
  3. Back up and regenerate the file via `docker login` (re-creates a valid config), or restore from version control/backup.
  4. Avoid hand-editing the file; use `docker logout` / `docker login` to mutate auths.

Example fix

// before — corrupt JSON (trailing comma)
{
  "auths": { "https://index.docker.io/v1/": { "auth": "..." }, }
}
// after — valid JSON
{
  "auths": { "https://index.docker.io/v1/": { "auth": "..." } }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate JSON before relying on the loader.
var v any
if err := json.Unmarshal(raw, &v); err != nil {
    return fmt.Errorf("config.json is not valid JSON: %w", err)
}

Try / catch

cfg, err := config.Load(dir)
if err != nil {
    return fmt.Errorf("failed to parse docker config: %w", err)
}

Prevention

When it happens

Trigger: config.Load -> LoadFromReader -> json.Decoder.Decode returns a non-EOF error, OR decodeAuth fails for a malformed `auths.<addr>.auth` base64 value. The error is wrapped as `parsing config file (<filename>): <err>`.

Common situations: Manual edits to `~/.docker/config.json` introduced a syntax error (trailing comma, unbalanced brace, smart quotes), a credential helper wrote a truncated/corrupt file, or an `auths` entry has a `auth` value that is not valid base64 or lacks the `username:password` colon separator (decodeAuth returns `invalid auth configuration file`).

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/76c7c660d730764d. Report an issue: GitHub.

Appendix: source

Thrown at cli/config/config.go:150

func load(configDir string) (*configfile.ConfigFile, error) {
	filename := filepath.Join(configDir, ConfigFileName)
	configFile := configfile.New(filename)

	file, err := os.Open(filename)
	if err != nil {
		if os.IsNotExist(err) {
			// It is OK for no configuration file to be present, in which
			// case we return a default struct.
			return configFile, nil
		}
		// Any other error happening when failing to read the file must be returned.
		return configFile, fmt.Errorf("loading config file: %w", err)
	}
	defer func() { _ = file.Close() }()
	err = configFile.LoadFromReader(file)
	if err != nil {
		err = fmt.Errorf("parsing config file (%s): %w", filename, err)
	}
	return configFile, err
}

// LoadDefaultConfigFile attempts to load the default config file and returns
// a reference to the ConfigFile struct. If none is found or when failing to load
// the configuration file, it initializes a default ConfigFile struct. If no
// credentials-store is set in the configuration file, it attempts to discover
// the default store to use for the current platform.
//
// Important: LoadDefaultConfigFile prints a warning to stderr when failing to
// load the configuration file, but otherwise ignores errors. Consumers should
// consider using [Load] (and [credentials.DetectDefaultStore]) to detect errors
// when updating the configuration file, to prevent discarding a (malformed)
// configuration file.
func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile {
	configFile, err := load(Dir())
	if err != nil {

View on GitHub (pinned to 4f84911bfe)