Dockerfile instructions

Dockerfile WORKDIR

Sets the directory used by later build instructions and runtime defaults. Creates the image directory if missing; relative values extend the previous working directory. Prefer absolute paths at the beginning of a stage. An initial absolute working directory avoids dependence on inherited working-directory settings.

Formal Syntax & Structure

docker syntaxdocker
WORKDIR /path/to/workdir

Parameters & Attributes

NameTypeDescription
pathstringWorking directory inside the image.

Working Example

Example Snippetdocker
FROM busybox:1.37WORKDIR /appWORKDIR reportsCMD ["pwd"]
Docker Reference