Skip to content

numeric-user-id

Dockerfilesuspiciousno fixdefault: offdockerfile/hadolint

Reports a USER whose user is a name instead of a number (USER app, USER app:1000). USER 1000, USER 1000:app and a variable are not reported: only the user part is checked, the group may be a name.

A name is looked up in the /etc/passwd of the image at run time, which tools outside the image cannot do. Kubernetes with runAsNonRoot: true refuses to start a container whose image user is a name (it cannot verify that the user is not root), and file permissions on mounted volumes use the number, not the name.

Create the user with a fixed id (useradd -u 1000 app) and write USER 1000.

Reported
...
ADD app.tar.gz /app/
ADD https://example.com/f /app/
USER app
USER 1000:1000
USER $UID
...
dockerfile:
lint:
rules:
numeric-user-id: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line numeric-user-id in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
hadolint DL3066 partial A variable is accepted whether or not an ARG defines it.