Docker, a widely adopted tool for packaging and deploying applications leverages Dockerfiles to build images. However, creating an optimal Dockerfile can be challenging, often leading to "Docker smells" or deviations from best practices. This paper presents a study of the impact of 14 Docker smells on the size of Docker images. To assess the size impact of Docker smells, we identified and repaired 16 145 Docker smells from 11 313 open-source Dockerfiles. We observe that the smells result in an average increase of 48.06 MB (4.6%) per smelly image. Depending on the smell type, the size increase can be up to 10%, and for some specific cases, the smells can represent 89% of the image size. Interestingly, the most impactful smells are related to package managers which are commonly encountered and are relatively easy to fix. To collect the perspective of the developers regarding the size impact of the Docker smells, we submitted 34 pull requests that repair the smells and we reported their impact on the Docker image to the developers. 26/34 (76.5%) of the pull requests have been merged and they contribute to a saving of 3.46 GB (16.4%). The developer's comments demonstrate a positive interest in addressing those Docker smells even when the pull requests have been rejected
翻译:Docker作为一种广泛采用的应用程序打包与部署工具,通过Dockerfile构建镜像。然而,创建最优Dockerfile颇具挑战性,常导致"Docker不良实践"(即偏离最佳实践的行为)。本文对14种Docker不良实践如何影响镜像尺寸展开研究。为评估其对镜像大小的影响,我们从11 313个开源Dockerfile中识别并修复了16 145处不良实践。研究发现,每个存在不良实践的镜像平均体积增加48.06 MB(4.6%)。根据不良实践类型的不同,体积增幅最高可达10%,特定案例中不良实践甚至占镜像总大小的89%。值得注意的是,影响最大的不良实践与包管理器相关——这类问题既常见又相对容易修复。为获取开发者对Docker不良实践体积影响的看法,我们提交了34个修复不良实践的拉取请求,并向开发者报告了其对Docker镜像的影响。其中26/34(76.5%)的拉取请求已被合并,累计节省3.46 GB(16.4%)存储空间。即便在部分请求被拒绝的情况下,开发者的反馈仍展现出解决这些Docker不良实践的积极意愿。