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.46GB (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 Smell"(即偏离最佳实践的问题)。本文针对14种Docker Smell对Docker镜像尺寸的影响展开研究。为评估Docker Smell的尺寸影响,我们从11 313个开源Dockerfile中识别并修复了16 145个Docker Smell。研究发现,每个含Smell的镜像平均体积增加48.06 MB(4.6%)。根据Smell类型不同,尺寸增幅最高可达10%,某些特定案例中Smell占比可达镜像体积的89%。值得注意的是,影响最大的Smell与包管理器相关,此类问题普遍存在且相对易于修复。为获取开发者对Docker Smell尺寸影响的观点,我们提交了34个修复Smell的拉取请求,并向开发者报告了这些请求对Docker镜像尺寸的影响。其中26/34(76.5%)的拉取请求已被合并,累计节约3.46GB(16.4%)存储空间。开发者的反馈表明,即使部分拉取请求被拒绝,他们仍积极关注这些Docker Smell的解决方案。