Abstract
Docker has become the industry standard for creating reproducible software environments, yet the promise of reproducibility is frequently undermined by the volatile nature of external dependencies. This paper presents Shipwright, a human-in-the-loop system designed to detect and repair Docker build failures that traditional static analysis tools overlook. By utilizing BERT-based natural language processing to cluster build log errors and employing human-authored repair rules, Shipwright can identify failures in over 70% of broken Dockerfiles. Our evaluation, conducted on a dataset of over 20,000 GitHub projects, demonstrates that Shipwright provides effective, automated patches that are highly valued by real-world maintainers.
1. Introduction: The Illusion of Reproducibility
While Docker is designed to ensure that software runs the same way regardless of the environment, the "reproducibility" of a Dockerfile is often an illusion. As software ecosystems evolve, the external environment—including package repositories, base images, and remote URLs—changes. A Dockerfile that built perfectly a year ago may fail today because a dependency has been moved or a version has been deprecated.
Existing quality assurance tools for Docker, such as Hadolint, rely primarily on static analysis. These tools are effective at identifying syntax errors or violations of best practices (e.g., missing version tags), but they are fundamentally blind to "dynamic" failures that only manifest during the execution of the build. Shipwright addresses this gap by shifting the focus from the code itself to the execution logs generated during failed builds.
2. The Scale of the Problem
To quantify the extent of the reproducibility crisis, researchers analyzed an expanded version of the binnacle dataset, consisting of Dockerfiles from GitHub repositories with 10 or more stars. Unlike previous studies that performed "out-of-context" builds (building the Dockerfile in isolation), this study performed in-context builds. This involved cloning the entire source repository to ensure that local file dependencies (referenced via COPY or ADD commands) were present.
The results were startling: 26.3% of the 20,526 Dockerfiles failed to build successfully. Perhaps most surprisingly, the popularity of a repository (measured by stars) did not correlate with build stability. Even high-profile projects frequently contained broken Dockerfiles, largely due to external environment shifts that occurred after the code was committed.
3. Methodology: Shipwright’s Pipeline
Shipwright employs a four-stage pipeline to bridge the gap between error detection and automated repair.
3.1 Data Collection and In-Context Building
Shipwright first attempts to build the Dockerfile within its original repository context. If the build fails, the system captures the full standard output (STDOUT) and standard error (STDERR) logs. These logs contain the critical clues needed to diagnose the failure.
3.2 Fix Extraction via BERT and Clustering
Because build logs are a messy combination of natural language, shell commands, and stack traces, Shipwright treats them as a natural language processing problem. The system uses a modified BERT (Bidirectional Encoder Representations from Transformers) model to generate mathematical embeddings of the error logs. BERT’s pre-training on diverse datasets, including technical forums like StackOverflow, allows it to understand the semantic meaning of different error messages.
These embeddings are then grouped using HDBSCAN, a density-based clustering algorithm. This allows Shipwright to group failures that may look different on the surface but share a common root cause—such as different packages failing because of the same underlying network timeout or a deprecated OS repository.
3.3 Human-in-the-Loop Intervention
Once failures are clustered, a human expert inspects a representative sample from each cluster to identify the root cause. The expert then writes a "repair rule" (a transformation function to modify the Dockerfile) or a "suggestion" (guidance for the developer). This human-in-the-loop approach ensures that the repairs are high-quality and contextually appropriate.
3.4 Patch Generation
When a new broken Dockerfile is encountered, Shipwright matches its build log against the existing database of clusters. If a match is found, the system automatically applies the corresponding repair rule or provides the relevant suggestion to the user.
4. Key Results and Impact
Shipwright’s performance was evaluated against traditional static analysis tools and real-world developer behavior:
- Superior Detection: Shipwright identified the cause of failure in 73.25% of broken files, whereas static analysis tools only caught between 20.6% and 33.8% of the same issues.
- Automated Repair Capability: The system successfully generated fully automated, valid repairs for 18.9% of the broken files in the dataset.
- Developer Acceptance: To test the real-world utility of the system, the authors submitted 45 pull requests containing Shipwright-generated fixes to GitHub maintainers. 19 of these were accepted (a 42.2% acceptance rate), confirming that the automated repairs met the standards of professional developers.
- Human-Equivalent Fixes: In a "time-travel" analysis, the researchers compared Shipwright’s suggestions to fixes later implemented by humans in the same repositories. Shipwright’s proposed repairs matched the human-authored patches in 22.77% of cases.
5. Discussion and Future Work
While Shipwright represents a significant advancement in Dockerfile maintenance, it faces challenges regarding the computational cost of scaling in-context builds. Running thousands of builds is resource-intensive and often limited by the throughput of the Docker daemon.
Furthermore, the system currently relies on human experts to define repair rules for new clusters. Future iterations of Shipwright could explore automated program synthesis to generate these repair functions without human intervention. Additionally, integrating Shipwright with language-specific package managers (e.g., npm, pip) could allow the system to resolve deeper application-level dependencies that occur during the build process.
6. Conclusion
Shipwright demonstrates that the "reproducibility crisis" in Docker is largely driven by external, dynamic factors that static analysis cannot reach. By treating build logs as a language and incorporating human expertise into the repair loop, Shipwright provides a scalable path toward more resilient and maintainable containerized environments.
Summary updated