is there a way to negate a pattern in .dockerignor

2019-06-15 00:34发布

问题:

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

回答1:

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.



标签: docker