WORKDIR instructions should be used with an absolute path for clarity and reliability.

Why is this an issue?

The WORKDIR instruction defines the working directory for any RUN, CMD, ENTRYPOINT, COPY, and ADD instructions that follow in the Dockerfile.
Using absolute paths helps to avoid any confusion or unexpected behavior that could arise, for example after changing the current directory in one of the previous instructions.

How to fix it

Code examples

Noncompliant code example

WORKDIR my_working_folder
WORKDIR .\\my_working_folder

Compliant solution

WORKDIR /images/my_working_folder
WORKDIR C:\\images\\my_working_folder

Resources

Documentation

Related rules