~/dejafu/blog/hadolint
Created a day ago
Last changed a day ago

hadolint-plugin: Dockerfile linting in VS Code

There is a handy tool for linting a Dockerfile in VS Code. The prerequisite is to have hadolint installed on your system. After you have installed the VS Code plugin, hadolint is automatically executed when opening a Dockerfile. But first things first...

What is hadolint?

With hadolint, Dockerfiles can be inspected according to best practices. The files will be checked against a comprehensive set of rules, which can be found here: https://github.com/hadolint/hadolint/wiki.

What is special about hadolint?

I've found that using hadolint alongside a tool like trivy allows you to benefit the most from the suggestions and recommendations these tools provide, because they complement each other.

This is because inspecting a Dockerfile with trivy returns different results than using hadolint. This is partly because trivy focuses more on security aspects. Just as an example, when I checked such a file with trivy, hadolint suggested applying the following changes to my Dockerfile:

Why using the VS Code plugin is convenient

Using the VS Code plugin for hadolint marks the recommended lines to be changed in VS Code, and after hovering over those cases, a tooltip with clickable links points to the respective part of the above-mentioned wiki.

Thanks for checking in. See you next time!

~ jacky