elastic/elasticsearch · error · GradleException
Failed to pull Docker base image [{baseImage}], all attempts
Error message
Failed to pull Docker base image [{baseImage}], all attempts failed What it means
Thrown by DockerBuildTask.DockerBuildAction.pullBaseImage() after a retry loop (maxAttempts = 10) exhausts all attempts to run `docker pull <baseImage>`. Each failed attempt is logged at WARN with the attempt count; only after all 10 fail does the GradleException fire, naming the base image. The retry exists to absorb transient registry/network errors, so reaching this exception means a persistent failure.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerBuildTask.java:233
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
try {
LoggedExec.exec(execOperations, spec -> {
maybeConfigureDockerConfig(spec);
spec.executable(docker);
spec.args("pull");
spec.environment("DOCKER_BUILDKIT", "1");
spec.args(baseImage);
});
return;
} catch (Exception e) {
LOGGER.warn("Attempt {}/{} to pull Docker base image {} failed", attempt, maxAttempts, baseImage);
}
}
// If we successfully ran `docker pull` above, we would have returned before this point.
throw new GradleException("Failed to pull Docker base image [" + baseImage + "], all attempts failed");
}
private void maybeConfigureDockerConfig(ExecSpec spec) {
String dockerConfig = System.getenv("DOCKER_CONFIG");
if (dockerConfig != null) {
spec.environment("DOCKER_CONFIG", dockerConfig);
}
}
@Override
public void execute() {
final Parameters parameters = getParameters();
if (parameters.getPull().get()) {
parameters.getBaseImages().get().forEach(this::pullBaseImage);
}
final List<String> tags = parameters.getTags().get();View on GitHub (pinned to db6a809a66)
Solutions
- Check the base image name and tag exist: `docker pull <baseImage>` manually and read the actual error (the task only logs 'failed', not the cause).
- Ensure registry credentials are available — set DOCKER_CONFIG to a dir with a valid config.json, or `docker login` to the registry.
- Verify the Docker daemon is running (`docker info`) and the host can reach the registry (network/proxy/DNS).
- If hitting Docker Hub rate limits, authenticate or use an authenticated mirror/registry.
- Re-run with `--info` to see the per-attempt WARN logs and inspect whether failures are consistent or intermittent.
Defensive patterns
Strategy: retry
Validate before calling
// Before the build, verify the base image is pullable: // run `docker pull <baseImage>` manually; ensure `docker login`/DOCKER_CONFIG is set for private registries.
Try / catch
// The task already retries 10x. To add outer resilience, catch GradleException
// and surface the underlying docker error by running `docker pull` manually first:
// try { pullBaseImage(img); } catch (GradleException e) { log docker daemon status; throw e; } Prevention
- Pre-pull base images manually to confirm they exist and credentials work.
- Configure DOCKER_CONFIG or run `docker login` for private/auth-required registries.
- Use an authenticated registry mirror to avoid Docker Hub rate limits.
- Ensure the Docker daemon is running (`docker info`) before starting the build.
When it happens
Trigger: The Docker build task is configured with `pull = true` (or a multi-platform push requires pulling the just-built image), and `docker pull` fails 10 times in a row. Causes: the base image name/tag does not exist in the registry; authentication to the registry is missing/wrong; network/DNS failure reaching the registry; Docker daemon not running or misconfigured; rate limits from Docker Hub.
Common situations: Building behind a corporate proxy without DOCKER_CONFIG/credentials configured; typo in the base image tag; Docker Hub rate-limiting on anonymous pulls; the base image is in a private registry the build cannot auth to; Docker daemon is stopped.
Related errors
- Failed to write marker file
- No manifest digest found in OCI image layout index [{indexJs
- Failed to read OCI image layout index [{indexJson}]
- Failed to fetch branch {normalizedBranch} from {sourceRepo}
- Interrupted while retrying download from: {}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/fa1745fbe892635e.
Report an issue: GitHub.