by hadolint

hadolint / hadolint

Dockerfile linter, validate inline bash, written in Haskell

4.2K Stars 185 Forks Last release: 10 days ago (v1.18.2) GNU General Public License v3.0 790 Commits 56 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Linux/OSX Build Status Windows Build status GPL-3 licensed GitHub release Github downloads pipecat

Haskell Dockerfile Linter

A smarter Dockerfile linter that helps you build best practice Docker images. The linter is parsing the Dockerfile into an AST and performs rules on top of the AST. It is standing on the shoulders of ShellCheck to lint the Bash code inside


:globewithmeridians: Check the online version on hadolint.github.io/hadolint Screenshot

How to use

You can run

locally to lint your Dockerfile.
hadolint --ignore DL3003 --ignore DL3006  # exclude specific rules
hadolint --trusted-registry my-company.com:500  # Warn when using untrusted FROM images

Docker comes to the rescue to provide an easy way how to run

on most platforms. Just pipe your
docker run
docker run --rm -i hadolint/hadolint < Dockerfile


You can download prebuilt binaries for OSX, Windows and Linux from the latest release page. However, if it doesn't work for you, please fall back to Docker,

or source installation.

If you are on OSX you can use brew to install

brew install hadolint

On Windows you can use scoop to install

scoop install hadolint

As shown before,

is available as a Docker container:
docker pull hadolint/hadolint

If you need a Docker container with shell access, use the Debian or Alpine variants of the Docker image:

docker pull hadolint/hadolint:latest-debian
docker pull hadolint/hadolint:latest-alpine

You can also build

locally. You need Haskell and the stack build tool to build the binary.
git clone https://github.com/hadolint/hadolint
cd hadolint
stack install


supports specifying the ignored rules using a configuration file. The configuration file should be in
format. This is one valid configuration file as an example:
  - DL3000
  - SC1010


can warn you when images from untrusted repositories are being used in Dockerfiles, you can append the
keys to the configuration file as shown below:
  - DL3000
  - SC1010


  • docker.io
  • my-company.com:5000

Configuration files can be used globally or per project. By default,

will look for a configuration file in the current directory with the name

The global configuration file should be placed in the folder specified by

, with the name
. In summary, the following locations are valid for the configuration file, in order or preference:
  • $PWD/.hadolint.yaml
  • $XDG_CONFIG_HOME/hadolint.yaml
  • ~/.config/hadolint.yaml

In windows, the

environment variable is used instead of

Additionally, you can pass a custom configuration file in the command line with the

hadolint --config /path/to/config.yaml Dockerfile

To pass a custom configuration file (using relative or absolute path) to a container, use the following command:

docker run --rm -i -v ./your/path/to/hadolint.yaml:/root/.config/hadolint.yaml hadolint/hadolint < Dockerfile

Inline ignores

It is also possible to ignore rules by using a special comment directly above the Dockerfile instruction you want to make an exception for. Ignore rule comments look like

# hadolint ignore=DL3001,SC1081
. For example:
# hadolint ignore=DL3006
FROM ubuntu

hadolint ignore=DL3003,SC1035

RUN cd /tmp && echo "hello!"

Inline ignores will only work if place directly above the instruction.


To get most of

it is useful to integrate it as a check to your CI or to your editor to lint your
as you write it. See our Integration docs.


An incomplete list of implemented rules. Click on the error code to get more detailed information.

  • Rules with the prefix

    originate from
    . Take a look at
    to find the implementation of the rules.
  • Rules with the

    prefix originate from ShellCheck (Only the most common rules are listed, there are dozens more)

Please create an issue if you have an idea for a good rule.

| Rule | Description | |:-------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------| | DL3000 | Use absolute WORKDIR. | | DL3001 | For some bash commands it makes no sense running them in a Docker container like ssh, vim, shutdown, service, ps, free, top, kill, mount, ifconfig. | | DL3002 | Last user should not be root. | | DL3003 | Use WORKDIR to switch to a directory. | | DL3004 | Do not use sudo as it leads to unpredictable behavior. Use a tool like gosu to enforce root. | | DL3005 | Do not use apt-get upgrade or dist-upgrade. | | DL3006 | Always tag the version of an image explicitly. | | DL3007 | Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag. | | DL3008 | Pin versions in apt-get install. | | DL3009 | Delete the apt-get lists after installing something. | | DL3010 | Use ADD for extracting archives into an image. | | DL3011 | Valid UNIX ports range from 0 to 65535. | | DL3012 | Provide an email address or URL as maintainer. | | DL3013 | Pin versions in pip. | | DL3014 | Use the

switch. | | DL3015 | Avoid additional packages by specifying --no-install-recommends. | | DL3016 | Pin versions in
. | | DL3017 | Do not use
apk upgrade
. | | DL3018 | Pin versions in apk add. Instead of
apk add 
apk add =
. | | DL3019 | Use the
switch to avoid the need to use
and remove
when done installing packages. | | DL3020 | Use
instead of
for files and folders. | | DL3021 |
with more than 2 arguments requires the last argument to end with
| | DL3022 |
COPY --from
should reference a previously defined
alias | | DL3023 |
COPY --from
cannot reference its own
alias | | DL3024 |
aliases (stage names) must be unique | | DL3025 | Use arguments JSON notation for CMD and ENTRYPOINT arguments | | DL3026 | Use only an allowed registry in the FROM image | | DL3027 | Do not use
as it is meant to be a end-user tool, use
instead | | DL3028 | Pin versions in gem install. Instead of
gem install 
gem install :
| | DL3029 | Do not use --platform flag with FROM. | | DL3030 | Use the
switch to avoid manual input
yum install -y 
| | DL3031 | Do not use
yum update
| | DL3032 |
yum clean all
missing after yum command. | | DL3033 | Specify version with
yum install -y -
| | DL3034 | Non-interactive switch missing from
zypper install -y
| | DL3035 | Do not use
zypper update
. | | DL3036 |
zypper clean
missing after zypper use. | | DL3037 | Specify version with
zypper install -y [=]
. | | DL4000 | MAINTAINER is deprecated. | | DL4001 | Either use Wget or Curl but not both. | | DL4003 | Multiple
instructions found. | | DL4004 | Multiple
instructions found. | | DL4005 | Use
to change the default shell. | | DL4006 | Set the
option -o pipefail before
with a pipe in it | | SC1000 |
is not used specially and should therefore be escaped. | | SC1001 | This
will be a regular
in this context. | | SC1007 | Remove space after
if trying to assign a value (or for empty string, use
var='' ...
). | | SC1010 | Use semicolon or linefeed before
(or quote to make it literal). | | SC1018 | This is a unicode non-breaking space. Delete it and retype as space. | | SC1035 | You need a space here | | SC1045 | It's not
foo &; bar
, just
foo & bar
. | | SC1065 | Trying to declare parameters? Don't. Use
and refer to params as
etc. | | SC1066 | Don't use $ on the left side of assignments. | | SC1068 | Don't put spaces around the
in assignments. | | SC1077 | For command expansion, the tick should slant left (` vs ´). | | SC1078 | Did you forget to close this double-quoted string? | | SC1079 | This is actually an end quote, but due to next char, it looks suspect. | | SC1081 | Scripts are case sensitive. Use
, not
. | | SC1083 | This
is literal. Check expression (missing
?) or quote it. | | SC1086 | Don't use
on the iterator name in for loops. | | SC1087 | Braces are required when expanding arrays, as in
. | | SC1095 | You need a space or linefeed between the function name and body. | | SC1097 | Unexpected
. For assignment, use
. For comparison, use
[ .. ]
[[ .. ]]
. | | SC1098 | Quote/escape special characters when using
, e.g.
eval "a=(b)"
. | | SC1099 | You need a space before the
. | | SC2002 | Useless cat. Consider cmd < file | .. or cmd file | .. instead. | | SC2015 | Note that A && B || C is not if-then-else. C may run when A is true. | | SC2026 | This word is outside of quotes. Did you intend to 'nest '"'single quotes'"' instead'? | | SC2028 |
won't expand escape sequences. Consider
. | | SC2035 | Use
-- *glob*
so names with dashes won't become options. | | SC2039 | In POSIX sh, something is undefined. | | SC2046 | Quote this to prevent word splitting | | SC2086 | Double quote to prevent globbing and word splitting. | | SC2140 | Word is in the form
(B indicated). Did you mean
? | | SC2154 | var is referenced but not assigned. | | SC2155 | Declare and assign separately to avoid masking return values. | | SC2164 | Use cd ... || exit in case
fails. |


If you are an experienced Haskeller we would be really thankful if you would tear our code apart in a review.


  1. Clone repository

    git clone --recursive [email protected]:hadolint/hadolint.git
  2. Install the dependencies

    stack install


The easiest way to try out the parser is using the REPL.

# start the repl
stack repl
# overload strings to be able to use Text
:set -XOverloadedStrings
# import parser library
import Language.Docker
# parse instruction and look at AST representation
parseText "FROM debian:jessie"


Run unit tests.

stack test

Run integration tests.



Dockerfile syntax is fully described in the Dockerfile reference. Just take a look at Syntax.hs in the

project to see the AST definition.


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.