Doctor : Optimizing Container Rebuild Efficiency by Instruction Re-Orchestration
Zhiling Zhu, Tieming Chen, Chengwei Liu, Han Liu, Qijie Song, Zhengzi Xu, Yang Liu · 2025
Read Doctor : Optimizing Container Rebuild Efficiency by Instruction Re-Orchestration by Zhiling Zhu, Tieming Chen, Chengwei Liu, Han Liu, Qijie Song, Zhengzi Xu, Yang Liu (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2504-01742.txt.
Introduction
Zhiling Zhu and six co-authors present Doctor, a tool that speeds up rebuilding software containers, in a 2025 paper. Containers, most often built with Docker, package an app with its full setup, but rebuilding them after each change eats time in testing pipelines.
Doctor reorders the build instructions so that steps likely to change sit where they cost least. It maps how instructions depend on each other and studies past edits to guess what will change next. A sorting method then finds a good order that keeps the build working the same way. On 2,000 projects from GitHub, Doctor improved about 93 percent of build files. Rebuild time fell by about 27 percent on average, and most builds behaved the same as before.
Catalog record
| CREATOR | Zhiling Zhu, Tieming Chen, Chengwei Liu, Han Liu, Qijie Song, Zhengzi Xu, Yang Liu |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 74 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2504-01742
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Doctor : Optimizing Container Rebuild Efficiency by Instruction Re-Orchestration Zhiling Zhu, Tieming Chen, Chengwei Liu, Han Liu, Qijie Song, Zhengzi Xu, Yang Liu Abstract . Containerization has revolutionized software deployment, with Docker leading the way due to its ease of use and consistent runtime environment. As Docker usage grows, optimizing Dockerfile performance, particularly by reducing rebuild time, has become essential for maintaining efficient CI/CD pipelines. However, existing optimization approaches primarily address single builds without considering the recurring rebuild costs associated with modifications and evolution, limiting long-term efficiency gains. To bridge this gap, we present Doctor , a method for improving Dockerfile build efficiency through instruction re-ordering that addresses key challenges: identifying instruction dependencies, predicting future modifications, ensuring behavioral equivalence, and managing the optimization’s computational complexity. We developed a comprehensive dependency taxonomy based on Dockerfile syntax and a historical modification analysis to prioritize frequently modified instructions. Using a weighted topological sorting algorithm, Doctor optimizes instruction order to minimize future rebuild time while maintaining functionality. Experiments on 2,000 GitHub repositories show that Doctor improves 92.75% of Dockerfiles, reducing rebuild time by an average of 26.5%, with 12.82% of files achieving over a 50% reduction. Notably, 86.2% of cases preserve functional similarity. These findings highlight best practices for Dockerfile management, enabling developers to enhance Docker efficiency through informed optimization strategies. DOI: XXXXXXX.XXXXXXX Conference: Proceedings of the 2025 ACM SIGSOFT International Symposium on Software Testing and Analysis; June 25–28, 2025; Trondheim, Norway ISBN: 978-1-4503-XXXX-X/18/06 1. Introduction The rapid adoption of containerization has revolutionized software deployment, with Docker becoming a key technology due to its ease of use and consistent runtime environment. Recent reports estimate the container market will reach USD 15.06 billion by 2028 ( con, 2024 ) . Containerization allows applications to bundle dependencies and configurations within isolated environments that share host resources, providing a more lightweight and efficient alternative to traditional virtualization ( Watada et al., 2019 ; Bentaleb et al., 2022 ; Rad et al., 2017 ) . However, as development teams increasingly rely on Docker, optimizing Dockerfile performance, particularly reducing rebuild time, has become a pressing concern. Dockerfiles, which define how containers are built, often contain inefficiencies that can lead to prolonged rebuild times, significantly impacting the development lifecycle. Excessive rebuild times not only slow down development but also increase resource consumption and hinder continuous integration and delivery (CI/CD) pipelines, where swift rebuilds are critical for rapid feedback. Common inefficiencies in Dockerfiles, such as inappropriate layer ordering ( doc, 2024f ) , redundant commands ( doc, 2024d ) , and missed caching opportunities ( doc, 2024e ) , contribute to these delays. For instance, placing frequently updated instructions at the top of the Dockerfile can prevent the Docker cache from being effectively utilized, leading to repeated rebuilds of downstream layers. However, considering the continuous maintenance and evolution activities, deficiency, such as excessive storage demands (i.e., large image layers) ( Zhao et al., 2019 ; Lin et al., 2020 ) , Dockerfile code smells ( Wu et al., 2020 ; Rosa et al., 2024b ; Durieux, 2024 ) , and outdated dependencies ( Zerouali et al., 2021 ; Zerouali et al., 2019 ) , is unavoidable. To improve build efficiency, research has been conducted to investigate solutions for the optimization of docker build performance. Huang et al. ( Huang et al., 2019 ) proposed FastBuild, a caching method that intercepts and caches remote file requests, achieving a 10x speed increase and substantial data reduction. Zhao et al. ( Zhao et al., 2020 ) and Durieux ( Durieux, 2024 ) have also conducted studies to investigate and find solutions to enhance storage efficiency and reduce Docker smells. However, these methods primarily target single builds, and none of the existing work has taken the recurring rebuild costs associated with ongoing modifications and project evolution into consideration, limiting their overall efficiency improvements. To this end, we aim to find out possible optimizations for Dockerfile that consider not only the single build efficiency but also the overall efficiency of docker rebuild in future maintenance activities. To bridge this gap, we still face the following challenges: C1: Inner Dependencies in Dockerfile. Considering that Dockerfiles are piled up by a series of Dockerfile Instructions ( ShabaniMirzaei, 2024 ) , there could be explicit or implicit dependencies that follow-up instructions would rely on components, variables, or settings executed by previous instructions. However, there are no existing taxonomies or tools for the identification of these dependencies. Moreover, Docker has defined its own Domain Specific Language (DSL) for the parsing and processing of Dockerfile, and there is no official DSL schema released for public usage, which makes it more challenging to precisely identify the dependencies. C2: Future Modification Prediction. Since we aim to optimize Dockerfiles towards their efficiency in future rebuilds, which instructions in the Dockerfiles could be more frequently modified should be considered in the optimization target function, while no existing solutions have been given. C3: Behavior Equivalence of Optimization. It is also crucial to ensure the equivalence of Dockerfile behavior during the Docker build to ensure its compatibility with its original user requirements. C4: State Space Explosion in Optimization Algorithm. The number of possible instruction permutations grows exponentially with Dockerfile length, posing a significant challenge in efficiently identifying optimal solutions that honor dependency constraints, it is also non-trivial to ensure the computation of optimization feasible for large and complex Dockerfiles. To address these challenges, we propose Doctor , a comprehensive approach to enhancing Dockerfile build efficiency through instruction re-ordering. Specifically, For C1 , we first revisited the official documentation of Dockerfile, and proposed an Extended Backus-Naur Form (EBNF) presentation for Dockerfile grammar, based on which, we implemented a robust parser for instruction interpretation and identified the key elements that may introduce dependency relations in dockerfile. Based on that, we also propose a comprehensive classification of Dockerfile inner dependency for dependency constraint identification. For C2 , we referred to the historical modification of Dockerfiles to investigate their possibility of future modifications. Specifically, considering that instructions could be altered for different purposes, it is difficult to distinguish modification and removal, we adopted similarity analyses with different measurement strategies to identify possible modifications, and aggregate the historical records to approach the future modification possibility. For C3 , we strictly followed the identified dependency relations among instructions to retain the dependencies of groups of instructions, and optimized instruction orders with these partial relationships. For C4 , we adopted a weighted topological sorting algorithm to optimize the instruction orders by minimizing its total build time with their future modification possibility considered. To avoid state space explosion, we greedily prioritized the instructions that have the largest occupation of building time cost in future rebuilds during the topological sorting algorithm. Our experiments demonstrate the effectiveness and efficiency of Doctor on 2,000 randomly selected popular GitHub repositories. Doctor improves 92.75% of Dockerfiles in the dataset, reducing future rebuild time by an average of 26.5%, with 12.82% of Dockerfiles achieving a reduction of over 50%. On average, Doctor takes only 77.55 seconds to optimize each Dockerfile. Moreover, Doctor also demonstrated an excellent performance on the preservation of original Dockerfile functionalities during the optimization. Our experiments also showed that 86.2% Dockerfiles still produced images with the same directory