Skip to main content

Documentation Index

Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt

Use this file to discover all available pages before exploring further.

Attempting to Copy file that is excluded by .dockerignore.
PropertyValue
SeverityWarning
CategoryCorrectness
DefaultEnabled

Description

When you use the ADD or COPY instructions in a Dockerfile, you should ensure that the files to be copied into the image do not match a pattern present in .dockerignore. Files which match the patterns in a .dockerignore file are not present in the context of the image when it is built. Trying to copy or add a file which is missing from the context will result in a build error.

Build context requirement

This rule needs build context information. In direct Dockerfile mode, pass a local context directory:
tally lint --context . Dockerfile
When linting a Bake or Compose entrypoint, tally uses the local context declared by the selected target or service:
tally lint docker-bake.hcl --target api
tally lint compose.yaml --service api
Remote, tar, git, and empty contexts are valid build declarations, but tally does not fetch or unpack them during linting. For those contexts, this rule only reports problems that can be determined without reading context files.

Examples

Given a .dockerignore containing */tmp/*: Bad:
FROM scratch
COPY ./tmp/helloworld.txt /helloworld.txt
Good:
FROM scratch
COPY ./forever/helloworld.txt /helloworld.txt

Reference