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

  1. 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).
  2. Ensure registry credentials are available — set DOCKER_CONFIG to a dir with a valid config.json, or `docker login` to the registry.
  3. Verify the Docker daemon is running (`docker info`) and the host can reach the registry (network/proxy/DNS).
  4. If hitting Docker Hub rate limits, authenticate or use an authenticated mirror/registry.
  5. 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

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


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/fa1745fbe892635e. Report an issue: GitHub.