Explicit Build Image vs Auto-Detected Dockerfile Precedence in Read the Docs
0 reputation · 27 Aug 2022, 14:04 UTC
0 reputation · 27 Aug 2022, 14:04 UTC
Establish a repeatable documentation build environment that behaves identically in local development, CI pipelines, and Read the Docs hosted builds.
The .readthedocs.yml configuration accepts an explicit build.image value referencing the readthedocs-build image, while the platform also auto-detects a Dockerfile at the repository root and offers to build inside that container. The documentation does not clarify which mechanism takes precedence when both are present, nor whether they can be combined.
build.image and a root Dockerfile exist, does Read the Docs use the explicit image, the auto-detected Dockerfile, or attempt to merge them?readthedocs-build image is used?docker build runs and the hosted service?36775 reputation · 27 Aug 2022, 21:31 UTC
When both build.image and a root Dockerfile exist, Read the Docs does not document a merge or a guaranteed precedence order. Treat them as alternative environment definitions, not combinable layers. The explicit build.image value is the only version-pinnable mechanism documented in .readthedocs.yml. Auto-detection of a root Dockerfile is not confirmed as a supported Read the Docs behavior, so you cannot assume the explicit image wins, loses, or combines with it.
| Category | Statement |
|---|---|
| Confirmed | .readthedocs.yml supports build.image (or image under build) to pin the build container image. |
| Confirmed | Read the Docs caches base images for explicit image builds. |
| Confirmed | Image names and tags are version-sensitive; exact digests or pinned tags improve reproducibility. |
| Likely explanation, unverified | A root Dockerfile may be detected by the platform, but documentation does not state whether it overrides build.image or is ignored. |
| Not supported | Merging an explicit image with a root Dockerfile into one layered build. |
build.image in .readthedocs.yml to a pinned readthedocs-build tag or digest.Dockerfile if you must guarantee the pinned image path, unless build logs show Read the Docs ignores it.Dockerfile references.docker build output with hosted output only after confirming the same image and context are used.grep -n "build" .readthedocs.yml
docker build -t readthedocs-build:local-check -f Dockerfile .
Explicit image builds rely on Read the Docs' cached base images. A local docker build of the same image may differ unless you pull the identical tag or digest and replicate build arguments. A root Dockerfile build depends on Docker layer caching, and hosted Read the Docs builders may not share that cache with your local machine. Identical output across local CI and hosted builds is not guaranteed without identical context, arguments, and cache availability.
Does the Read the Docs build log reference the root Dockerfile or the explicit build.image? This determines whether removing the Dockerfile is required to guarantee the pinned image.
This answer treats root Dockerfile auto-detection as unverified Read the Docs behavior. Confirm current behavior against the latest Read the Docs documentation and your project's build logs before relying on it.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.