UndefinedVar
Output
Usage of undefined variable '$foo'Description
This check ensures that environment variables and build arguments are correctly declared before being used. While undeclared variables might not cause an immediate build failure, they can lead to unexpected behavior or errors later in the build process.
This check does not evaluate undefined variables for RUN, CMD, and
ENTRYPOINT instructions where you use the shell form.
That's because when you use shell form, variables are resolved by the command
shell.
It also detects common mistakes like typos in variable names. For example, in the following Dockerfile:
FROM alpine
ENV PATH=$PAHT:/app/binThe check identifies that $PAHT is undefined and likely a typo for $PATH:
Usage of undefined variable '$PAHT' (did you mean $PATH?)Examples
❌ Bad: $foo is an undefined build argument.
FROM alpine AS base
COPY $foo .✅ Good: declaring foo as a build argument before attempting to access it.
FROM alpine AS base
ARG foo
COPY $foo .❌ Bad: $foo is undefined.
FROM alpine AS base
ARG VERSION=$foo✅ Good: the base image defines $PYTHON_VERSION
FROM python AS base
ARG VERSION=$PYTHON_VERSION
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
