require-dockerfile-workdir
Require a WORKDIR instruction in Dockerfiles.
Targeted pattern scopeâ
- Repository-root
Dockerfilecontent.
What this rule reportsâ
This rule reports Dockerfiles that do not set an explicit working directory.
Why this rule existsâ
Without WORKDIR, command path behavior can be inconsistent across images and
future image updates.
â Incorrectâ
FROM node:22-alpine
RUN npm ci
â Correctâ
FROM node:22-alpine
WORKDIR /app
RUN npm ci
When not to use itâ
Disable this rule if container build scripts intentionally rely on the default root working directory.
Rule catalog ID: R091