is there a way to negate a pattern in .dockerignor

2019-06-15 00:11发布

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

标签: docker
1条回答
【Aperson】
2楼-- · 2019-06-15 00:40

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.

查看更多
登录 后发表回答