mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Apply a 127GB default WCOW Sandbox size globally
This applies the 127GB default WCOW Sandbox size to not just `RUN` under `docker build` (as was previously the case) but to `COPY` and `ADD` under `docker build` and also to `docker run`. It also removes an inconsistency that the 127GB size was not applied when `--platform windows` was not passed to `docker build`, but WCOW was still used as a platform default, e.g. Docker Desktop for Windows in Windows Containers mode. Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This commit is contained in:
parent
142b2b785b
commit
56d378a88f
2 changed files with 32 additions and 23 deletions
|
@ -11,7 +11,6 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
|
@ -448,8 +447,7 @@ func (b *Builder) probeAndCreate(dispatchState *dispatchState, runConfig *contai
|
|||
func (b *Builder) create(runConfig *container.Config) (string, error) {
|
||||
logrus.Debugf("[BUILDER] Command to be executed: %v", runConfig.Cmd)
|
||||
|
||||
isWCOW := runtime.GOOS == "windows" && b.platform != nil && b.platform.OS == "windows"
|
||||
hostConfig := hostConfigFromOptions(b.options, isWCOW)
|
||||
hostConfig := hostConfigFromOptions(b.options)
|
||||
container, err := b.containerManager.Create(runConfig, hostConfig)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -462,7 +460,7 @@ func (b *Builder) create(runConfig *container.Config) (string, error) {
|
|||
return container.ID, nil
|
||||
}
|
||||
|
||||
func hostConfigFromOptions(options *types.ImageBuildOptions, isWCOW bool) *container.HostConfig {
|
||||
func hostConfigFromOptions(options *types.ImageBuildOptions) *container.HostConfig {
|
||||
resources := container.Resources{
|
||||
CgroupParent: options.CgroupParent,
|
||||
CPUShares: options.CPUShares,
|
||||
|
@ -485,16 +483,6 @@ func hostConfigFromOptions(options *types.ImageBuildOptions, isWCOW bool) *conta
|
|||
LogConfig: defaultLogConfig,
|
||||
ExtraHosts: options.ExtraHosts,
|
||||
}
|
||||
|
||||
// For WCOW, the default of 20GB hard-coded in the platform
|
||||
// is too small for builder scenarios where many users are
|
||||
// using RUN statements to install large amounts of data.
|
||||
// Use 127GB as that's the default size of a VHD in Hyper-V.
|
||||
if isWCOW {
|
||||
hc.StorageOpt = make(map[string]string)
|
||||
hc.StorageOpt["size"] = "127GB"
|
||||
}
|
||||
|
||||
return hc
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,15 @@ import (
|
|||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// filterDriver is an HCSShim driver type for the Windows Filter driver.
|
||||
const filterDriver = 1
|
||||
const (
|
||||
// filterDriver is an HCSShim driver type for the Windows Filter driver.
|
||||
filterDriver = 1
|
||||
// For WCOW, the default of 20GB hard-coded in the platform
|
||||
// is too small for builder scenarios where many users are
|
||||
// using RUN or COPY statements to install large amounts of data.
|
||||
// Use 127GB as that's the default size of a VHD in Hyper-V.
|
||||
defaultSandboxSize = "127GB"
|
||||
)
|
||||
|
||||
var (
|
||||
// mutatedFiles is a list of files that are mutated by the import process
|
||||
|
@ -73,6 +80,10 @@ func (c *checker) IsMounted(path string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
type storageOptions struct {
|
||||
size uint64
|
||||
}
|
||||
|
||||
// Driver represents a windows graph driver.
|
||||
type Driver struct {
|
||||
// info stores the shim driver information
|
||||
|
@ -80,8 +91,9 @@ type Driver struct {
|
|||
ctr *graphdriver.RefCounter
|
||||
// it is safe for windows to use a cache here because it does not support
|
||||
// restoring containers when the daemon dies.
|
||||
cacheMu sync.Mutex
|
||||
cache map[string]string
|
||||
cacheMu sync.Mutex
|
||||
cache map[string]string
|
||||
defaultStorageOpts *storageOptions
|
||||
}
|
||||
|
||||
// InitFilter returns a new Windows storage filter driver.
|
||||
|
@ -100,6 +112,11 @@ func InitFilter(home string, options []string, uidMaps, gidMaps []idtools.IDMap)
|
|||
return nil, fmt.Errorf("windowsfilter failed to create '%s': %v", home, err)
|
||||
}
|
||||
|
||||
size, err := units.RAMInBytes(defaultSandboxSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("windowsfilter failed to parse default size '%s': %v", defaultSandboxSize, err)
|
||||
}
|
||||
|
||||
d := &Driver{
|
||||
info: hcsshim.DriverInfo{
|
||||
HomeDir: home,
|
||||
|
@ -107,6 +124,9 @@ func InitFilter(home string, options []string, uidMaps, gidMaps []idtools.IDMap)
|
|||
},
|
||||
cache: make(map[string]string),
|
||||
ctr: graphdriver.NewRefCounter(&checker{}),
|
||||
defaultStorageOpts: &storageOptions{
|
||||
size: uint64(size),
|
||||
},
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
@ -231,8 +251,13 @@ func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt
|
|||
return fmt.Errorf("Failed to parse storage options - %s", err)
|
||||
}
|
||||
|
||||
sandboxSize := d.defaultStorageOpts.size
|
||||
if storageOptions.size != 0 {
|
||||
if err := hcsshim.ExpandSandboxSize(d.info, id, storageOptions.size); err != nil {
|
||||
sandboxSize = storageOptions.size
|
||||
}
|
||||
|
||||
if sandboxSize != 0 {
|
||||
if err := hcsshim.ExpandSandboxSize(d.info, id, sandboxSize); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -935,10 +960,6 @@ func (d *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) {
|
|||
return &fileGetCloserWithBackupPrivileges{d.dir(id)}, nil
|
||||
}
|
||||
|
||||
type storageOptions struct {
|
||||
size uint64
|
||||
}
|
||||
|
||||
func parseStorageOpt(storageOpt map[string]string) (*storageOptions, error) {
|
||||
options := storageOptions{}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue