.dockerignore
如何处理异常?
例如,除了src/web/public
之外,我想忽略src/
目录中的所有内容。
我试过..。
.git
src
!src/web/public
似乎不管用。
无论哪种方式,docker build .
都会显示Sending build context to Docker daemon 20.63 MB
。
发布于 2014-10-30 04:05:39
.dockerignore
似乎不会处理异常。如果有一个广为人知的语法,那就是you could propose the change and make a pull request。
在tag 1.3 of commands.go中,我们可以看到:
ignore, err := ioutil.ReadFile(path.Join(root, ".dockerignore"))
// ...
options := &archive.TarOptions{
Compression: archive.Uncompressed,
Excludes: excludes,
}
context, err = archive.TarWithOptions(root, options)
for _, include := range options.Includes {
// ...
skip, err := fileutils.Matches(relFilePath, options.Excludes)
if err != nil {
log.Debugf("Error matching %s", relFilePath, err)
return err
}
if skip {
if f.IsDir() {
return filepath.SkipDir
}
return nil
}
// ...
}
发布于 2016-03-25 20:05:10
只是想补充一下,以防其他人遇到这个问题,在.dockerignore文件中支持docker 1.7.0中的排除。因此,问题中的示例!src/web/public
实际上是有效的
https://docs.docker.com/engine/reference/builder/#dockerignore-file
发布于 2019-06-05 08:43:28
使用my response to another Using https://stackoverflow.com/a/51429852/2419069,您可以使用以下.dockerignore
文件:
# Ignore everything
**
# Allow /src/web/public directory
!/src/web/public/**
# You can also ignore unnecessary files inside the /src/web/public to make your image even smaller.
**/*~
**/*.log
**/.DS_Store
**/Thumbs.db
https://stackoverflow.com/questions/26636566
复制相似问题