Skip to content

expose-port-range

Dockerfilecorrectnessno fixdefault: errordockerfile/hadolint

Reports an EXPOSE with a port number above 65535. Several ports, /tcp and /udp suffixes and ranges (8000-70000) are all checked; a variable is not.

TCP and UDP ports are 16-bit numbers from 0 to 65535. A larger number is a typo (a digit too many), and Docker rejects it as an invalid port, so the build fails.

Reported
...
WORKDIR /app
WORKDIR $HOME
EXPOSE 8080 70000
EXPOSE 80/tcp 443
...
dockerfile:
lint:
rules:
expose-port-range: error # off, warn, error (default)

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line expose-port-range in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
hadolint DL3011 full