testcontainers/testcontainers-java · error · NotFoundException

No config supplied. Checked in order: configFile (file not…

Error message

No config supplied. Checked in order: configFile (file not found), DOCKER_AUTH_ENV_VAR (not set)

What it means

RegistryAuthLocator resolves Docker registry credentials for private image pulls. It looks first at the DOCKER_AUTH_CONFIG environment variable (JSON config) and then at the Docker config file (default ~/.docker/config.json, or the file set via withConfigFile). If neither exists it throws NotFoundException, meaning Testcontainers has no credentials to authenticate the pull.

Solutions

  1. Run `docker login <registry>` on the machine/user running tests to create ~/.docker/config.json
  2. Set the DOCKER_AUTH_CONFIG environment variable to a JSON docker config (e.g. {"auths":{"registry":{"auth":"base64(user:pass)"}}})
  3. If using a custom DOCKER_CONFIG, verify it points to the directory containing config.json
  4. Check that the test process actually runs as the user who holds the Docker credentials (CI often switches users)

Example fix

// CI script before
export DOCKER_AUTH_CONFIG='{"auths":{"https://index.docker.io/v1/":{"auth":"dXNlcjpwYXNz"}}}'
Defensive patterns

Strategy: validation

Validate before calling

boolean hasAuth() {
    if (System.getenv("DOCKER_AUTH_CONFIG") != null) return true;
    String dockerConfig = System.getenv().getOrDefault("DOCKER_CONFIG",
        System.getProperty("user.home") + "/.docker");
    return new File(dockerConfig, "config.json").exists();
}

Try / catch

try {
    startContainer();
} catch (NotFoundException e) {
    if (e.getMessage().contains("No config supplied")) {
        throw new IllegalStateException("Run 'docker login' or set DOCKER_AUTH_CONFIG before tests", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: TestcontainersConfiguration.getInstance().getRegistryAuthLocator().getAuthConfig(...) during container start when: DOCKER_AUTH_CONFIG env var is unset AND the resolved docker config file does not exist (no ~/.docker/config.json, or a custom DOCKER_CONFIG path points nowhere).

Common situations: CI machines that never ran `docker login`; users on imageless/kaniko setups expecting env-based auth; DOCKER_CONFIG env var pointing to a directory without config.json; pulling a private image (e.g. from a corporate registry) whose credentials were only configured in a different user's home directory.

Related errors


AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12). Data as JSON: /api/errors/453aa778736aac0b. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/testcontainers/utility/RegistryAuthLocator.java:196

    private JsonNode getDockerAuthConfig() throws Exception {
        log.debug(
            "RegistryAuthLocator has configFile: {} ({}) configEnv: {} ({}) and commandPathPrefix: {}",
            configFile,
            configFile.exists() ? "exists" : "does not exist",
            DOCKER_AUTH_ENV_VAR,
            configEnv != null ? "exists" : "does not exist",
            commandPathPrefix
        );

        if (configEnv != null) {
            log.debug("RegistryAuthLocator reading from environment variable: {}", DOCKER_AUTH_ENV_VAR);
            return OBJECT_MAPPER.readTree(configEnv);
        } else if (configFile.exists()) {
            log.debug("RegistryAuthLocator reading from configFile: {}", configFile);
            return OBJECT_MAPPER.readTree(configFile);
        }

        throw new NotFoundException(
            "No config supplied. Checked in order: " +
            configFile +
            " (file not found), " +
            DOCKER_AUTH_ENV_VAR +
            " (not set)"
        );
    }

    private AuthConfig findExistingAuthConfig(final JsonNode config, final String reposName) throws Exception {
        final Map.Entry<String, JsonNode> entry = findAuthNode(config, reposName);

        if (entry != null && entry.getValue() != null && entry.getValue().size() > 0) {
            final AuthConfig deserializedAuth = OBJECT_MAPPER
                .treeToValue(entry.getValue(), AuthConfig.class)
                .withRegistryAddress(entry.getKey());

            if (
                StringUtils.isBlank(deserializedAuth.getUsername()) &&

View on GitHub (pinned to 8e549514e3)