Ming, HuaKsontini, EmnaKessentini, MarouaneWilson, StevenBagherzadeh, MehdiSrauy, Sam2025-07-112025-07-112024-01-01https://hdl.handle.net/10323/18788In today’s fast-paced software development environment, containerization has emerged as a cornerstone of modern infrastructure, enabling consistent and scalable deployments across varied platforms. Docker, as the leading containerization platform, plays a critical role in this landscape, but the management of Dockerfiles - scripts that automate the creation of container images - presents significant challenges. These challenges include the accumulation of technical debt, inefficient image sizes, prolonged build durations, and the emergence of anti-patterns, all of which can undermine the efficiency, maintainability, and quality of Docker-based projects. This dissertation presents and advances a suite of techniques and tools to enhance the quality of Docker projects through carefully targeted refactoring strategies, anti-pattern detection, and the mitigation of technical debt. It begins with an empirical study of open-source Docker projects, identifying 38 Docker-specific refactoring techniques and nine distinct categories of technical debt. These findings illuminate the unique challenges inherent in Dockerfile management, which differ fundamentally from those in traditional software development due to Docker's Infrastructure as Code (IaC) nature. Building on these insights, the research introduces DRMiner, a tool designed to detect and analyze refactorings within Dockerfiles. Utilizing an Enhanced Abstact Syntax Tree (E-AST) approach, DRMiner addresses the specific complexities of Docker artifacts, automating the identification of refactoring opportunities and significantly reducing the manual effort required for Dockerfile maintenance. The dissertation also proposes a novel method for the specification and detection of Docker-specific anti-patterns, expanding the scope beyond traditional code smells to address broader design flaws. This method defines five new anti-patterns and develops a metric-based framework for their automated detection. Finally, this research delves into automating Dockerfile refactoring through large language models (LLMs). The findings reveal that LLM-driven refactoring reduces image sizes and builds durations and enhances maintainability and understandability, outperforming manual refactoring methods. Together, these contributions provide a robust, empirically grounded framework for enhancing the quality and sustainability of Docker projects, offering valuable tools and insights for both practitioners and researchers in containerizationSoftware designDetecting and refactoring technical debt for software containers