有没有办法否定.dockerignore中的模式? [英] is there a way to negate a pattern in .dockerignore?

查看:419
本文介绍了有没有办法否定.dockerignore中的模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图否定一个.dockerignore中的模式。使用Go的filepath.Match规则完成Globbing。检查后,似乎我们可以使用^字符来取消模式。



.dockerfile

  * 
^ Dockerfile
^ web-app / dist

但是,当我建立docker时,我有以下错误:

  Dockerfile被.dockerignore模式排除*'

你知道是否可以完成我想要的?



谢谢

解决方案

自版本 1.7.0 ,现在是可以的。



现在使用按照您的期望工作,并在官方 Dockerfile参考中记录。



以下是从上述链接获取的示例:

  * / temp * 
* / * / temp *
temp?
* .md
!LICENSE.md

!LICENSE.md 将导致LICENSE.md被包含在Docker构建上下文中,尽管 *。md 规则。


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

解决方案

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.

这篇关于有没有办法否定.dockerignore中的模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆