本文整理匯總了Golang中github.com/docker/engine-api/types.ImageBuildOptions.CPUPeriod方法的典型用法代碼示例。如果您正苦於以下問題:Golang ImageBuildOptions.CPUPeriod方法的具體用法?Golang ImageBuildOptions.CPUPeriod怎麽用?Golang ImageBuildOptions.CPUPeriod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/engine-api/types.ImageBuildOptions
的用法示例。
在下文中一共展示了ImageBuildOptions.CPUPeriod方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BuildImage
// BuildImage builds the image according to specified options
func (d *stiDocker) BuildImage(opts BuildImageOptions) error {
dockerOpts := dockertypes.ImageBuildOptions{
Tags: []string{opts.Name},
NoCache: true,
SuppressOutput: false,
Remove: true,
ForceRemove: true,
}
if opts.CGroupLimits != nil {
dockerOpts.Memory = opts.CGroupLimits.MemoryLimitBytes
dockerOpts.MemorySwap = opts.CGroupLimits.MemorySwap
dockerOpts.CPUShares = opts.CGroupLimits.CPUShares
dockerOpts.CPUPeriod = opts.CGroupLimits.CPUPeriod
dockerOpts.CPUQuota = opts.CGroupLimits.CPUQuota
}
glog.V(2).Infof("Building container using config: %+v", dockerOpts)
resp, err := d.client.ImageBuild(context.Background(), opts.Stdin, dockerOpts)
if err != nil {
return err
}
defer resp.Body.Close()
// since can't pass in output stream to engine-api, need to copy contents of
// the output stream they create into our output stream
_, err = io.Copy(opts.Stdout, resp.Body)
return err
}
示例2: BuildImage
// BuildImage builds the image according to specified options
func (d *stiDocker) BuildImage(opts BuildImageOptions) error {
dockerOpts := dockertypes.ImageBuildOptions{
Tags: []string{opts.Name},
NoCache: true,
SuppressOutput: false,
Remove: true,
ForceRemove: true,
}
if opts.CGroupLimits != nil {
dockerOpts.Memory = opts.CGroupLimits.MemoryLimitBytes
dockerOpts.MemorySwap = opts.CGroupLimits.MemorySwap
dockerOpts.CPUShares = opts.CGroupLimits.CPUShares
dockerOpts.CPUPeriod = opts.CGroupLimits.CPUPeriod
dockerOpts.CPUQuota = opts.CGroupLimits.CPUQuota
}
glog.V(2).Infof("Building container using config: %+v", dockerOpts)
ctx, cancel := getDefaultContext(((1<<63 - 1) * time.Nanosecond)) // infinite duration ... go does not expost max duration constant
defer cancel()
resp, err := d.client.ImageBuild(ctx, opts.Stdin, dockerOpts)
if err != nil {
return err
}
defer resp.Body.Close()
// since can't pass in output stream to engine-api, need to copy contents of
// the output stream they create into our output stream
_, err = io.Copy(opts.Stdout, resp.Body)
return err
}