podman build does not properly ignore absolute paths in .containerignore files. #25746
Labels
kind/bug
Categorizes issue or PR as related to a bug.
macos
MacOS (OSX) related
remote
Problem is in podman-remote
stale-issue
Issue Description
When a (non-exception) path in a .containerignore starts with a
/
, making it an absolute path, it is not ignored. The documentation states that it should be:Steps to reproduce the issue
Steps to reproduce the issue
echo -e "FROM fedora:41\nCOPY * /tmp/context/\nRUN ls -lRa /tmp/context" > Containerfile
echo "/foo" > .containerignore
touch foo
echo "foo" > .containerignore
Describe the results you received
The build process included the file
foo
in the output of theRUN ls -lRa /tmp/context
command for the first build, but not the second.Describe the results you expected
The build process does not include the file
foo
in the output of theRUN ls -lRa /tmp/context
command in either build.podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
No response
Additional information
I believe this is an issue with
NewPatternMatcher()
ingithub.com/containers/storage/pkg/fileutils
. There is code in the function to remove a leading/
if the rule is an exception, but not if the rule is an exclusion.This looks to have been missed in containers/storage@94b63f0.
Docker uses
github.com/moby/patternmatcher/ignorefile.ReadAll()
to read and clean the paths from an ignorefile. It looks like podman has two implementations, but both are missing some of the cleaning behaviors present in the.../patternmatcher/ignorefile
package's implementation.The text was updated successfully, but these errors were encountered: