All Dockerfile linters are either a command line tool or a webpage and they borrow the best practices from Docker’s “Best practices for writing Dockerfiles“. I am listing here the most popular tools to lint Dockerfiles.
- hadolint: opensource linter written in Haskell. Rules are basically defined in code as seen in the Rule.sh source file here. There is also a fork of it here.
- dockerfile lint: this is the linter provided by the project atomic. This Linter runs in nodejs. Rules are defined via regular expressions as seen in here. This linter is based on the dockerfile checker which is written on Python and also reads the rules from a YAML file called dockerfile_rules.yaml.
- Dockerlint: another nodejs linter. Rules are written in CoffeeScript.
- Plug-ins for Visual Studio Code: Visual Studio Code plug-ins offer the richiest developer experience. They offer autocomplete for Dockerfiles and Docker compose plus syntax highlighting. The most complete plugin is Docker Support from Microsoft, there are other plug-ins including the Docker Linter and CodeLift (requires an online account).
- Linter for dockerfile: this is a project from RedHat Labs. I didn’t find any detail about its internal working.
Javier Andrés Cáceres Alvis