Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Using a Dedicated Hadolint Config File

using-a-dedicated-hadolint-config-file.jpg

Instead of using command line flags, this helps make your config more portable and easier to run in different environments.

Quick Jump:

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.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments