COPY --chown and ADD --chown are silently ignored on Windows containers.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | Correctness |
| Default | Enabled |
| Auto-fix | Yes (removes the --chown flag) |
Description
Windows containers do not use POSIX file ownership (uid:gid). The--chown flag on COPY and
ADD instructions is silently ignored when building for Windows — BuildKit accepts the flag
without error, but the resulting files have no ownership change applied.
Users who add --chown=user:group on a Windows stage expect ownership to be set, but the flag
has no effect. This rule catches the dead flag at lint time so authors can remove it or understand
that it is a no-op.
Why this matters
- Silent no-op — the build succeeds but
--chowndoes nothing on Windows - Misleading intent — other maintainers may assume file ownership is being managed
- Cross-platform confusion — multi-stage Dockerfiles with both Linux and Windows stages may
copy patterns from Linux stages where
--chownis meaningful
Examples
Violation
After fix (--fix)
No violation
Related rules
tally/copy-after-user-without-chown— suggests adding--chownon Linux stages after a non-rootUSER(complementary; fires on opposite condition)tally/windows/no-stopsignal— another Windows-specific correctness rule for silently ignored instructionstally/windows/no-run-mounts— Windows-specific correctness rule for unsupportedRUN --mountflags