hadolint / hadolint-action

GitHub action for Hadolint, A Dockerfile linting tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I ignore certain problems?

tschm opened this issue · comments

e.g. i would love to do something along these lines

name: Lint Dockerfile

on: push

jobs:
  linter:
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v2

      - name: Lint Dockerfile
        uses: brpaz/hadolint-action@master
        with:
          dockerfile: "Dockerfile"
          ignore: "DL3013"

Who can I achieve that?

Right now it´s not possible to pass ignore rules as arguments. You can create an .hadolint.yaml file in the root of your repository and configure your rules that way.

See: https://github.com/hadolint/hadolint#configure

+1
This would make it a lot more easier and flexible, particularly in the event that you validate more than one Dockerfile and you need a different rule set for each validation. Unfortunately the yaml config file can only be used globally or needs to be passed explicitly.

This is my use case here. I use two validation stages. One for the main Dockerfile and one for a "dev" release containing additional developing and debug tools which should not be in the final production image.

      -
        name: Validate root Dockerfile
        uses: brpaz/hadolint-action@v1.2.1
        with:
          dockerfile: Dockerfile
      -
        name: Validate dev Dockerfile
        uses: brpaz/hadolint-action@v1.2.1
        with:
          dockerfile: with-xdebug/Dockerfile

And here in the dev image with-xdebug/Dockerfile I refer to the latest version of the root dockerfile.

FROM ghcr.io/made/alpine-nginx-php8:latest

So linter runs over this line and of course fails because I get the latest version instead of explicitly requiring.
But the same rule should NOT apply to the main 'Dockerfile` so I cannot deactivate this globally.

I would love to see the configuration here for example like this.

      -
        name: Validate root Dockerfile
        uses: brpaz/hadolint-action@v1.2.1
        with:
          dockerfile: Dockerfile
      -
        name: Validate dev Dockerfile
        uses: brpaz/hadolint-action@v1.2.1
        with:
          dockerfile: with-xdebug/Dockerfile
          ignore: 
            - DL3000
            - SC1010