Refactoring for Dockerfile Quality: A Dive into Developer Practices and Automation Potential

📅 2025-01-23
📈 Citations: 0
Influential: 0
📄 PDF

career value

181K/year
🤖 AI Summary
Dockerfile quality systematically degrades over project evolution, manifesting as substantial increases in image size and build time, while manual refactoring lags behind. This paper presents the first large-scale evolutionary analysis of 600 open-source Dockerfiles, empirically characterizing degradation patterns. We propose the first end-to-end automated Dockerfile refactoring method integrating in-context learning (ICL) with score-driven example selection, augmented by static/dynamic feature analysis and seamless CI/CD integration. Evaluation shows our approach achieves, on average, a 32% reduction in image size and a 6% decrease in build time; improves readability in 77% and maintainability in 91% of cases. Compared to manual refactoring, it delivers twice the improvement; against the state-of-the-art tool PARFUM, it yields a tenfold gain—marking the first quantifiable superiority in Dockerfile refactoring effectiveness.

Technology Category

Application Category

📝 Abstract
Docker, the industry standard for packaging and deploying applications, leverages Infrastructure as Code (IaC) principles to facilitate the creation of images through Dockerfiles. However, maintaining Dockerfiles presents significant challenges. Refactoring, in particular, is often a manual and complex process. This paper explores the utility and practicality of automating Dockerfile refactoring using 600 Dockerfiles from 358 open-source projects. Our study reveals that Dockerfile image size and build duration tend to increase as projects evolve, with developers often postponing refactoring efforts until later stages in the development cycle. This trend motivates the automation of refactoring. To achieve this, we leverage In Context Learning (ICL) along with a score-based demonstration selection strategy. Our approach leads to an average reduction of 32% in image size and a 6% decrease in build duration, with improvements in understandability and maintainability observed in 77% and 91% of cases, respectively. Additionally, our analysis shows that automated refactoring reduces Dockerfile image size by 2x compared to manual refactoring and 10x compared to smell-fixing tools like PARFUM. This work establishes a foundation for automating Dockerfile refactoring, indicating that such automation could become a standard practice within CI/CD pipelines to enhance Dockerfile quality throughout every step of the software development lifecycle.
Problem

Research questions and friction points this paper is trying to address.

Dockerfile Maintenance
Software Image Size
Build Time Optimization
Innovation

Methods, ideas, or system contributions that make the work stand out.

Automated Dockerfile Refactoring
In-Context Learning
Image Size Reduction