Skip to content

Files

Latest commit

 

History

History
31 lines (20 loc) · 998 Bytes

DL3045.md

File metadata and controls

31 lines (20 loc) · 998 Bytes

Pattern: Use of relative COPY without WORKDIR set

Issue: -

Description

While COPYing to a relative path is not problematic per se, errors happen, when changes are introduced to the WORKDIR without updating the destination of the COPY command. Since it is easy to overlook this relationship, Hadolint emits this warning when no WORKDIR is set and COPY has a relative destination. This case is error prone and either setting the COPY-destination absolute or the WORKDIR explicitly will reduce the probability of having an error. It is assumed, that when a WORKDIR is set, the programmer will make sure it works well together with the destination of the COPY statements.

Example of incorrect code:

FROM scratch
COPY foo bar

Example of correct code:

FROM scratch
COPY foo /bar

# alternative
FROM scratch
WORKDIR /
COPY foo bar

Further Reading