Rule-based refactoring tool for fixing Dockerfile smells detected by hadolint.
A detailed description of the tool and its evaluation can be found in the preprint of the source article.
The first step is to install hadolint. Next, clone the repository and install the requirements:
conda create -n dockleaner python=3.7
conda activate dockleaner
pip install -r requirements.txt
Dockleaner was tested on macOS
and Arch Linux
using Python 3.7
.
Run python3 dockleaner.py --help
to see the following help message:
optional arguments:
-h, --help show this help message and exit
--cache, -c If selected, clears the cache of pulled image
--overwrite, -o Set TRUE to overwrite the target Dockerfile after the
fix
--ignore rules_to_ignore [rules_to_ignore ...], -i rules_to_ignore [rules_to_ignore ...]
The rules that the solver must ignore
--rule rules_to_fix [rules_to_fix ...]
Specify one or more specific rules to fix
required arguments:
--path filepath, -p filepath
The path of the Dockerfile
--last-edit dockerfile_date, -d dockerfile_date
Last edit date of the given Dockerfile. Format "YYYY-
MM-DD".
Thus, the command:
python3 -u dockleaner.py -p Dockerfile -d "2023-04-12" --rule "DL3008" --overwrite
will fix the Dockerfile Dockerfile
by pinning versions for apt packages and overwriting the file.
- 📆 DL3000
- 📆 DL3002
- ✅ DL3003
- 📆 DL3004
- 📆 DL3005
- ✅ DL3006
- ✅ DL3007
- ✅ DL3008
- ✅ DL3009
- 📆 DL3013
- 🆗 DL3014
- ✅ DL3015
- 📆 DL3016
- ✅ DL3020
- 📆 DL3022
- 📆 DL3024
- ✅ DL3025
- 📆 DL3027
- 📆 DL3028
- 📆 DL3029
- 🆗 DL3042
- 📆 DL3045
- 🆗 DL3047
- ✅ DL3048
- ✅ DL3059
- ✅ DL4000
- 📆 DL4001
- 📆 DL4003
- ✅ DL4006
Legend:
- ✅ Supported
- 🆗 Supported, but not validated via pull requests
- 📌 To be implemented
- 📆 For future implementation
The project is licensed under the MIT License. See LICENSE for details.
The first prototype of Dockleaner was developed by Alessandro Giagnorio. Withouth his work, this project would not have been possible. The prototype has been extended and improved by Simone Scalabrino and Giovanni Rosa which is currently the maintainer of the project.
The proposal of the study, which includes the tool and its evaulation, was first presented at ICSME'22 - Registered Reports Track.
@article{rosa2022fixing,
title={Fixing dockerfile smells: An empirical study},
author={Rosa, Giovanni and Scalabrino, Simone and Oliveto, Rocco},
journal={arXiv preprint arXiv:2208.09097},
year={2022}
}
Next, the complete study has been accepted at Empirical Software Engineering (EMSE).
@article{rosa2024fixingsmells,
author = {Giovanni Rosa and
Federico Zappone and
Simone Scalabrino and
Rocco Oliveto},
title = {Fixing Dockerfile Smells: An Empirical Study},
journal = {Empirical Software Engineering},
year = {2024},
note = {To appear}
}