Reputation: 1576
I am trying to negate a pattern in a .dockerignore. The Globbing is done using Go's filepath.Match rules. After checking the source, it seems we can negate a pattern by using ^ character.
.dockerfile
*
^Dockerfile
^web-app/dist
However, when i docker build, I have the following error:
Dockerfile was excluded by .dockerignore pattern '*'
Do you know if its possible to accomplish what I want ?
Thanks
Upvotes: 22
Views: 8382
Reputation: 1493
As of version 1.7.0, this is now possible.
Negating with !
now works as you would expect and is documented in the official Dockerfile reference.
Here's an example taken from the link above:
*/temp*
*/*/temp*
temp?
*.md
!LICENSE.md
The line !LICENSE.md
will cause LICENSE.md to be included in the Docker build context despite the *.md
rule.
Upvotes: 30