-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception patterns in .dockerignore do not support wildcard directories #30018
Comments
try: ! **/*.txt |
The special So with that, here's how the bug happens in
Note that if the This is the heart of the bug. Directories can't be used as wildcards for exception rules because of this prefix matching business. |
This issue still exists... Any update on this? .dockerignore
Dockerfile
tree output
|
This is a pain in the ***. |
This is a frustration every single time I want to make a Docker build for my projects using a whitelist-style dockerignore. Maybe I've just been using Docker wrong from the start, but I don't understand how dockerignore files, a tremendously simple, yet fundamental feature of Docker, can just be left broken and neglected for literally years. Are whitelist-style dockerignore files simply an unsupported use-case? Also, this seems like it might be the same as this issue: #23693 |
Are there any work-arounds to this? |
Worst thing is; there's no workaround for this. I've been manually adding each directory to it. Why is it so hard to make this file to behave just like |
Any updates on this issue? |
A wild guess: original thinking was to include whatever functionality Perhaps it's time to reconsider, docker build is used together with git a lot, it would be awesome if same format was supported! One may even hope for |
I'd second that. An ability to |
Any Updates? |
created an "epic" to collect related issues; #40319 |
See moby/moby#30018; using wildcard directories in negation patterns is not supported
I'm also having this issue, please fix |
The only thing I wish to COPY is
(well, |
I would also love to use such a feature 👍 . Use case is the same as @arvenil 's, i.e., it would be much easier to keep track of what I'm sending to the build context using an allow list rather than a deny list. |
I may have a workaround for you:
This will copy all directories and files without extensions. The exclusions work if the directories are not ignored. So you only have to add files without extensions (like Dockerfile) to the ignore list. |
@Yuyan-Li I ended up doing something similar but hit another limitation, any files with more than one dot on its name will be missed:
|
Description
Exception patterns in
.dockerignore
do not support wildcard directories. I expect to be able to write exception rules like!*/*.txt
.Steps to reproduce the issue:
.dockerignore
(specs):Dockerfile
:find .
from it:Describe the results you received:
Output of
docker run
:./recipes/cake.txt
, matching the exception rule!*/*.txt
, is missing.Describe the results you expected:
./recipes/cake.txt
, matching the exception rule!*/*.txt
, is present.Additional information you deem important (e.g. issue happens only occasionally):
This change was likely introduced by #20872. cc/ @duglin @icecrime @vdemeester
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
This issue should affect only the client.
The text was updated successfully, but these errors were encountered: