numeric-user-id
What it does
Section titled “What it does”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.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”...ADD app.tar.gz /app/ADD https://example.com/f /app/USER appUSER 1000:1000USER $UID...Configuration
Section titled “Configuration”dockerfile: lint: rules: numeric-user-id: warn # off (default), warn, errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line numeric-user-id in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”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. |