Skip to content

workdir-absolute

Dockerfilecorrectnessno fixdefault: offdockerfile/hadolint

Reports a WORKDIR with a relative path. A path is absolute when it starts with /, a drive letter (C:) or a variable ($HOME, ${DIR}/x). Quotes around the path make no difference, and a relative path is reported also after an absolute WORKDIR.

A relative WORKDIR is resolved against the previous WORKDIR, or against the one of the base image, which you may not control. Adding an instruction or changing the base image then moves the directory without any sign in this line. An absolute path always means the same place.

Reported
...
FROM alpine:3@sha256:abc
WORKDIR app
WORKDIR /app
WORKDIR $HOME
...
dockerfile:
lint:
rules:
workdir-absolute: warn # off (default), warn, error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line workdir-absolute 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 DL3000 full