Using a Dedicated Hadolint Config File
Instead of using command line flags, this helps make your config more portable and easier to run in different environments.
A couple of years ago I did a more in-depth post and video on the value of using Hadolint to lint your Dockerfiles. This time around we’ll focus on some changes to make configuring it more portable.
This is something I’ve applied to all of my example Docker starter apps and all projects for quite some time. Here’s a commit showing the diff.
It mostly comes down to replacing inline flags such as -t style
with a
.hadolint.yaml
file and defining your config there. For example,
failure-threshold: "style"
. Here’s a reference to its config file
docs.
This is beneficial because now you don’t need to worry about passing flags to
hadolint
when you call it. This means it doesn’t matter if you’re running it
locally, in CI or configured through your code editor. They will all use
the same configuration. It’s also something you can commit to version control
so others can have the same set up.
# Demo Video
Timestamps
- 0:18 – Running Hadolint
- 0:44 – Benefits of a config file
- 1:54 – The old set up with flags
How do you configure Hadolint? Let me know below.