Docker is a popular tool for developers and organizations to package, deploy, and run applications in a lightweight, portable container. One key component of Docker is the Dockerfile, a simple text file that specifies the steps needed to build a Docker image. While Dockerfiles are easy to create and use, creating an optimal image is complex in particular since it is easy to not follow the best practices, when it happens we call it Docker smell. To improve the quality of Dockerfiles, previous works have focused on detecting Docker smells, but they do not offer suggestions or repair the smells. In this paper, we propose, Parfum, a tool that detects and automatically repairs Docker smells while producing minimal patches. Parfum is based on a new Dockerfile AST parser called Dinghy. We evaluate the effectiveness of Parfum by analyzing and repairing a large set of Dockerfiles and comparing it against existing tools. We also measure the impact of the repair on the Docker image in terms of build failure and image size. Finally, we opened 35 pull requests to collect developers' feedback and ensure that the repairs and the smells are meaningful. Our results show that Parfum is able to repair 806 245 Docker smells and have a significant impact on the Docker image size, and finally, developers are welcoming the patches generated by Parfum while merging 20 pull requests.
翻译:摘要:Docker是开发者和组织用于在轻量、可移植容器中打包、部署和运行应用程序的流行工具。Docker的关键组件之一是Dockerfile,这是一个简单的文本文件,指定了构建Docker镜像所需的步骤。尽管Dockerfile易于创建和使用,但构建最优镜像却较为复杂,尤其容易因未遵循最佳实践而产生Docker坏味。为提升Dockerfile质量,先前研究主要聚焦于检测Docker坏味,但未提供修复建议或自动修复能力。本文提出Parfum工具,该工具可检测并自动修复Docker坏味,同时生成最小化补丁。Parfum基于名为Dinghy的新型Dockerfile AST解析器。我们通过分析并修复大规模Dockerfile集,并与现有工具进行对比,评估了Parfum的有效性。同时,我们测量了修复对Docker镜像在构建失败率与镜像大小方面的影响。最后,我们提交了35个拉取请求以收集开发者反馈,确保修复措施与坏味定义的合理性。结果表明,Parfum能够修复806,245个Docker坏味,并对镜像尺寸产生显著影响。此外,开发者对Parfum生成的补丁持开放态度,其中20个拉取请求已被合并。