Dockerfile rules
tx0 checks Dockerfiles with 43 rules, 8 of them in the default tier. Files that say a tool generated them are skipped. Each rule's page explains what it finds and what it leaves alone.
Default: 8 rules
Bugs and security problems with measured precision. They run without a tx0.toml.
-
tx0/dockerfile:copy-from-unknown-stagedefaultCOPY --from names a stage that no earlier FROM defines
-
tx0/dockerfile:copy-sources-to-filedefaultCOPY or ADD has several sources and a destination that does not end with
/, which fails -
tx0/dockerfile:duplicate-stage-namedefaultTwo stages have the same name
-
tx0/dockerfile:invalid-exposed-portdefaultEXPOSE names a port outside 1 to 65535 or a protocol other than tcp, udp and sctp
-
tx0/dockerfile:repeated-cmddefaultA stage has several CMD instructions and only the last takes effect
-
tx0/dockerfile:repeated-entrypointdefaultA stage has several ENTRYPOINT instructions and only the last takes effect
-
tx0/dockerfile:repeated-healthcheckdefaultA stage has several HEALTHCHECK instructions and only the last takes effect
-
tx0/dockerfile:unknown-instructiondefaultA line starts with a word that is no Dockerfile instruction
Recommended: 18 rules
Likely bugs, resource and performance problems.
-
tx0/dockerfile:add-from-urlrecommendedADD downloads a file from a URL without a checksum
-
tx0/dockerfile:apt-install-without-yesrecommendedApt-get installs packages without
-y, so it waits for a confirmation that a build cannot give -
tx0/dockerfile:apt-update-in-own-steprecommendedapt-get updateruns in a step of its own, so later installs can use a stale cached index -
tx0/dockerfile:base-image-latestrecommendedA stage starts from the
latesttag of an image, which points at a new image after each release -
tx0/dockerfile:base-image-untaggedrecommendedA stage starts from an image named without a tag, which means its
latesttag -
tx0/dockerfile:global-arg-not-redeclaredrecommendedA stage uses an argument declared only before the first FROM, which is empty inside stages
-
tx0/dockerfile:last-user-rootrecommendedThe final stage switches back to root after its last USER, so the container runs as root
-
tx0/dockerfile:package-signature-check-offrecommendedA package manager in the build installs packages without checking their signatures or source
-
tx0/dockerfile:path-replacedrecommendedENV sets PATH without the previous PATH, which drops the directories of the base image
-
tx0/dockerfile:relative-workdirrecommendedWORKDIR is a relative path before any absolute one, so it depends on the base image's directory
-
tx0/dockerfile:remote-script-into-shellrecommendedA RUN instruction pipes a download into a shell, which runs whatever the server sends
-
tx0/dockerfile:secret-in-build-variablerecommendedAn ENV or ARG with a credential's name has a value written into the Dockerfile, which stays in the image
-
tx0/dockerfile:shell-form-entrypointrecommendedENTRYPOINT is in shell form, so the program runs under
sh -cand does not get stop signals -
tx0/dockerfile:ssh-port-exposedrecommendedThe image exposes port 22, the port of an SSH server
-
tx0/dockerfile:sudo-in-runrecommendedA RUN instruction uses sudo, which builds do not need and which leaves sudo in the image
-
tx0/dockerfile:tls-verification-offrecommendedA download in the build or a setting of the image turns off the check of server certificates
-
tx0/dockerfile:world-writable-permissionsrecommendedA RUN instruction makes files writable by every user of the container
-
tx0/dockerfile:yum-install-without-yesrecommendedYum, dnf or zypper installs packages without assuming yes, so it waits for a confirmation
Strict: 17 rules
Code that can be written more plainly.
-
tx0/dockerfile:apk-cache-keptstrictapk addkeeps the package index in the layer -
tx0/dockerfile:apt-installs-recommendsstrictApt-get installs recommended packages as well as the ones named
-
tx0/dockerfile:apt-lists-keptstrictA step installs with apt-get and leaves the package lists in its layer
-
tx0/dockerfile:apt-upgradestrictA step upgrades all packages of the base image, which a newer base image does better
-
tx0/dockerfile:apt-version-unpinnedstrictApt-get installs packages without a version, so the image changes with the archive
-
tx0/dockerfile:base-image-without-digeststrictA stage starts from an image named by tag alone, which its publisher can point at other content
-
tx0/dockerfile:cd-in-runstrictA RUN instruction changes directory with
cd, which lasts only for that step -
tx0/dockerfile:dnf-cache-keptstrictYum or dnf installs packages and leaves its cache in the layer
-
tx0/dockerfile:fixed-platformstrictA FROM instruction fixes the platform of its stage to one architecture
-
tx0/dockerfile:maintainer-instructionstrictMAINTAINER is deprecated in favor of a label
-
tx0/dockerfile:missing-healthcheckstrictThe image has no HEALTHCHECK, so a running but stuck container counts as healthy
-
tx0/dockerfile:no-userstrictThe final stage never sets a user, so the container runs as the base image's user, often root
-
tx0/dockerfile:npm-install-in-buildstrictnpm installresolves dependencies anew in the build instead of installing the lock file -
tx0/dockerfile:pip-cache-keptstrictPip installs packages and keeps its download cache in the layer
-
tx0/dockerfile:pip-version-unpinnedstrictPip installs a package by name alone, so the image changes with each release of the package
-
tx0/dockerfile:pipe-without-pipefailstrictA RUN instruction pipes commands under
sh, so the failure of a command before the last goes unnoticed -
tx0/dockerfile:shell-form-cmdstrictCMD is in shell form, so the program runs under
sh -cand does not get stop signals