Dockerfilelint analyzes Dockerfiles to look for common mistakes and help enforce best practices.
100K+
Dockerfilelint is an npm module that analyzes a Dockerfile and looks for common traps, mistakes and helps enforce best practices:
Start unit tests with npm test
./bin/dockerfilelint <path/to/Dockerfile>
You can configure the linter by creating a .dockerfilelintrc with the following syntax:
rules:
uppercase_commands: off
The keys for the rules can be any file in the /lib/reference.js file. At this time, it's only possible to disable rules. They are all enabled by default.
The following rules are supported:
required_params
uppercase_commands
from_first
invalid_line
sudo_usage
apt-get_missing_param
apt-get_recommends
apt-get-upgrade
apt-get-dist-upgrade
apt-get-update_require_install
apkadd-missing_nocache_or_updaterm
apkadd-missing-virtual
invalid_port
invalid_command
expose_host_port
label_invalid
missing_tag
latest_tag
extra_args
missing_args
add_src_invalid
add_dest_invalid
invalid_workdir
invalid_format
apt-get_missing_rm
(Replace the pwd/Dockerfile with the path to your local Dockerfile)
sudo docker run -v `pwd`/Dockerfile:/Dockerfile dockerfilelint /Dockerfile
If you don't want to install this locally you can try it out on https://fromlatest.io.
FROMFROM scratch without a tagFROM <image>@<digest> syntaxMAINTAINERRUN--no-install-recommends flagrm -rf /var/lib/apt/lists/* in the same layerapt-get upgrade or apt-get dist-upgradeapt-get update without apt-get install on the same line--no-cache flag or be paired with an --update flag with rm -rf /var/cache/apk/* in the same layerCMDCMD layer is allowedLABELEXPOSEENVENVENV line to reduce cache layer countADDADD command could be a COPY, then COPY is preferredADD to fetch remote files is discouraged because they cannot be removed from the layerCOPYCOPY multiple files on a single command to best use cacheENTRYPOINTVOLUMEUSERWORKDIRWORKDIR can only expand variables previously set in ENV commandsARGONBUILDSTOPSIGNALContent type
Image
Digest
Size
74.2 MB
Last updated
about 6 years ago
docker pull replicated/dockerfilelint