Sign inSign up

kgrv/hadolint

By kgrv

Updated about 1 month ago

An interface for Haskell Dockerfile Linter.

Image
Developer tools
0

2.7K

kgrv/hadolint repository overview

DESCRIPTION

A kgrv/mini:init image for hadolint interface.

SUPPORTED TAGS

SUPPORTED ARCHITECTURES

OS/ARCHDescription
linux/amd6464-bit x86 architecture for Linux operating systems
linux/arm6464-bit ARM architecture for Linux operating systems

PARAMETERS

TypeContainerFunction
Volume/mntBind mount volume

USAGE

Usage Information

docker run --tty -v $(pwd):/mnt kgrv/hadolint --help
Usage: hadoint [-b <bin>] [-c <config>] [-n] [-q] [-s] [-d] [--trace] [--version] [--] [<dockerfiles...>]

An interface for Haskell Dockerfile Linter.
https://hub.docker.com/r/kgrv/hadolint

Positional Arguments:
  dockerfiles       list of Dockerfiles (scan on empty)

Options:
  -b, --bin         set Hadolint binary path
  -c, --config      set configuration file
  -n, --no-fail     exit code disregards rules violation
  -q, --quiet       quiet except WARN/ERROR
  -s, --scan        scan directories for Dockerfiles
  -d, --debug       enable debug mode
  --trace           enable trace mode (verbose)
  --version         display version
  --help, help      display usage information

Configuration File

docker run --tty -v $(pwd):/mnt kgrv/hadolint --config FILE DOCKERFILE

hadolint detects the following paths by default:

  • /mnt/.config/hadolint.yaml
  • /mnt/.hadolint/hadolint.yaml
  • /mnt/hadolint/config.yaml
  • /mnt/.hadolint.yaml

Directories Scan

Scan is the default mode when no Dockerfile is given, override the arguments by passing -s/--scan flag. The program will walk directories and find any Dockerfile match. It will then pass them to hadolint to be linted.

docker run --tty -v $(pwd):/mnt kgrv/hadolint
 INFO  hadoint > Scan for Dockerfiles
 DEBUG hadoint > Dockerfiles: [
    "/mnt/acso/Dockerfile",
    "/mnt/alpine/Dockerfile",
    "/mnt/code/Dockerfile",
    ...

Exit Code

Tip

Pass -n/--no-fail flag to disregard any rules violation, this allows non-disruptive integration.

hadoint will exit 2 for external errors, 1 for general errors, and 0 for success. The program prints out the code before exits, $? to capture the exit code.

Success:
 INFO  hadoint > Exit Code: 0

Failure:
 ERROR hadoint > Exit Code: 1

Output to File

  • Output everything including the interface by passing -t/--tty
docker run --tty -v $(pwd):/mnt kgrv/hadolint DOCKERFILE 2>&1 | tee FILE
  • Remove ANSI colors before output to the file
docker ... 2>&1 | sed 's/\x1b\[[0-9;]*[mGKHF]//g' | tee FILE

Example

Running kgrv/hadolint on its source with .hadolint.yaml configured for our workflow:

 INFO  hadoint > Start Hadolint Interface
 INFO  hadoint > Scan for Dockerfiles
 INFO  hadoint > Run Hadolint
/mnt/Dockerfile:3 DL3006 info: Always tag the version of an image explicitly
/mnt/Dockerfile:19 DL3022 info: `COPY --from` should reference a previously defined `FROM` alias
/mnt/Dockerfile:24 DL3022 info: `COPY --from` should reference a previously defined `FROM` alias
/mnt/Dockerfile:35 DL3022 info: `COPY --from` should reference a previously defined `FROM` alias
 INFO  hadoint > Runtime 55.515ms
 INFO  hadoint > Exit Code: 0
 INFO  hadoint > Bye!

Tag summary

Content type

Image

Digest

sha256:77b8aaf36

Size

14.1 MB

Last updated

about 1 month ago

docker pull kgrv/hadolint