Pattern: Use of relative path for WORKDIR
Issue: -
For clarity and reliability, prefer using absolute paths for your WORKDIR
. Also, you should use WORKDIR
instead of proliferating instructions like RUN cd … && do-something
, which are hard to read, troubleshoot, and maintain.
Example of incorrect code:
WORKDIR usr/src/app
Example of correct code:
WORKDIR /usr/src/app
When using environment replacements.
FROM busybox
ENV foo /bar
WORKDIR ${foo} # WORKDIR /bar