gpt4 book ai didi

docker - 有没有办法否定 .dockerignore 中的模式?

转载 作者:IT老高 更新时间:2023-10-28 12:40:58 29 4
gpt4 key购买 nike

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

.docker 文件

*
^Dockerfile
^web-app/dist

但是,当我 docker build 时,出现以下错误:

Dockerfile was excluded by .dockerignore pattern '*'

你知道它是否有可能完成我想要的吗?

谢谢

最佳答案

从版本 1.7.0 开始,这现在是可能的。

! 取反现在可以正常工作,并记录在官方 Dockerfile reference 中。 .

这是从上面的链接中摘取的一个例子:

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

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

关于docker - 有没有办法否定 .dockerignore 中的模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26776269/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com