Exceptions in .dockerignore

后端 未结 3 1142
天命终不由人
天命终不由人 2021-01-11 19:35

How does .dockerignore handle exceptions?

For example, I would like to ignore everything from the src/ directory except for src/web/p

3条回答
  •  礼貌的吻别
    2021-01-11 19:49

    It does not appear that .dockerignore handles exceptions. If there is a well-known syntax for this, you could propose the change and make a pull request.

    In tag 1.3 of commands.go we see this:

        ignore, err := ioutil.ReadFile(path.Join(root, ".dockerignore"))
        // ...
        options := &archive.TarOptions{
            Compression: archive.Uncompressed,
            Excludes:    excludes,
        }
        context, err = archive.TarWithOptions(root, options)
    

    and in archive.go:

        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
                }
                // ...
        }
    

提交回复
热议问题