Lint Dockerfile

Jagadeesh Malakannavar
1 min readApr 11, 2022

--

When I started reviewing Dockerfiles, I found disparity using instructions like label, copy, add etc. Sometime dockerfiles written by same engineer, written for different components, look quite different. With such structured code, code quality becomes a challenge. We can test code for its functionality but poorly structured code affect reliability, efficiency and pose a maintenance challenge.

To fix this problem, linting is added to workflow. For linting
dockerfiles, we tried hadolint. It has good documentation
and easy to use. And cab easily integrated in our workflow.

Hadolint helps maintain consistent code. All dockerfiles look very
familiar when it is opened. It has pointed out some misused
instructions, errors which would have escaped during code review. We
have integrated with githooks so that before code is committed,
hadolint runs and stops commit if error is detected.

We can design our own rulesets to make quality better. Also setup CI
pipeline for quality gate in Jenkins so that regularly this job
executes and lint dockerfile.

--

--

No responses yet