Skip to main content
COPY to a relative destination without WORKDIR set.

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. It is assumed that when a WORKDIR is set, the programmer will make sure it works well together with the COPY destinations.

Examples

Problematic code

Correct code

or:

Auto-fix

Inserts an explicit WORKDIR instruction before the first COPY with a relative destination.
  • Fast path (no registry access): suggests WORKDIR /app as a conventional default (FixSuggestion, requires --fix-unsafe).
  • With --slow-checks: resolves the base image’s actual WORKDIR from the registry and uses that value (FixSafe, applied with --fix).

Reference