{"record":{"id":"5ed4faf2b73db714","repo":"spring-projects/spring-boot","slug":"error-reading-docker-configuration-file","errorCode":null,"errorMessage":"Error reading Docker configuration file '{}'","messagePattern":"Error reading Docker configuration file '(.+?)'","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerConfigurationMetadata.java","lineNumber":166,"sourceCode":"\t}\n\n\tprivate static String asHash(String currentContext) {\n\t\ttry {\n\t\t\tMessageDigest digest = MessageDigest.getInstance(\"SHA-256\");\n\t\t\tbyte[] hash = digest.digest(currentContext.getBytes(StandardCharsets.UTF_8));\n\t\t\treturn HexFormat.of().formatHex(hash);\n\t\t}\n\t\tcatch (NoSuchAlgorithmException ex) {\n\t\t\tthrow new IllegalStateException(\"SHA-256 is not available\", ex);\n\t\t}\n\t}\n\n\tprivate static String readPathContent(Path path) {\n\t\ttry {\n\t\t\treturn Files.readString(path);\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\tthrow new IllegalStateException(\"Error reading Docker configuration file '\" + path + \"'\", ex);\n\t\t}\n\t}\n\n\tstatic final class DockerConfig extends MappedObject {\n\n\t\tprivate final @Nullable String currentContext;\n\n\t\tprivate final @Nullable String credsStore;\n\n\t\tprivate final Map<String, String> credHelpers;\n\n\t\tprivate final Map<String, Auth> auths;\n\n\t\tprivate DockerConfig(JsonNode node) {\n\t\t\tsuper(node, MethodHandles.lookup());\n\t\t\tthis.currentContext = valueAt(\"/currentContext\", String.class);\n\t\t\tthis.credsStore = valueAt(\"/credsStore\", String.class);\n\t\t\tthis.credHelpers = mapAt(\"/credHelpers\", JsonNode::stringValue);","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerConfigurationMetadata.java#L148-L184","documentation":"readPathContent calls Files.readString(path) and wraps any IOException in IllegalStateException. Note the message always says 'Docker configuration file' but readPathContent is shared by both createDockerConfig (config.json) and createDockerContext (meta.json); the path substituted into the message tells you which file failed. Because existence was already checked by the caller, an IOException here almost always means a permission/race/encoding problem rather than a missing file.","triggerScenarios":"Files.readString(path) at line 163 throws IOException: permission denied, path is a directory, file bytes are not valid UTF-8 and cannot be decoded, or the file was removed between the caller's exists() check and the read.","commonSituations":"config.json or meta.json chmod 000 or owned by another user; file on a network mount that became inaccessible; antivirus locking the file on Windows; concurrent process deleting the file.","solutions":["Check and fix permissions: `ls -l <path>` then `chmod +r <path>`.","Ensure the path is a regular file, not a directory or special file.","If this is a concurrency/race, ensure a single owner of the docker config dir during the build."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-check readability of the docker config files\nPath cfg = resolveConfigPath();\nif (Files.exists(cfg) && !Files.isReadable(cfg)) {\n    throw new IllegalStateException(\"Docker config file \" + cfg + \" is not readable (check permissions).\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    build.run();\n} catch (IllegalStateException ex) {\n    if (ex.getCause() instanceof IOException\n            && ex.getMessage().startsWith(\"Error reading Docker configuration file\")) {\n        // hint: check file permissions / mount health\n    }\n    throw ex;\n}","preventionTips":["Ensure the user running the build has read access to ~/.docker (chmod +r).","Avoid concurrent processes that delete or rewrite the docker config dir mid-build.","On network mounts, ensure the mount stays healthy during the build."],"tags":["docker","configuration","io","filesystem","buildpack"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}