cpuset added

This commit is contained in:
Dmitry 2018-01-24 23:03:01 +02:00
parent 656c8a8c2f
commit cd0b52d19f
3 changed files with 20 additions and 0 deletions

View file

@ -355,6 +355,21 @@ func resourceDockerContainer() *schema.Resource {
},
},
"cpuset": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, es []error) {
value := v.(string)
if !regexp.MustCompile(`^\d+([,-]\d+)*$`).MatchString(value) {
es = append(es, fmt.Errorf("%q must be comma or hyphen separated string of cpus to use", k))
}
return
},
},
"log_driver": &schema.Schema{
Type: schema.TypeString,
Optional: true,

View file

@ -167,6 +167,10 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
hostConfig.CPUShares = int64(v.(int))
}
if v, ok := d.GetOk("cpuset"); ok {
hostConfig.CPUSetCPUs = v.(string)
}
if v, ok := d.GetOk("log_opts"); ok {
hostConfig.LogConfig.Config = mapTypeMapValsToString(v.(map[string]interface{}))
}

View file

@ -73,6 +73,7 @@ The following arguments are supported:
* `memory_swap` - (Optional, int) The total memory limit (memory + swap) for the
container in MBs. This setting may compute to `-1` after `terraform apply` if the target host doesn't support memory swap, when that is the case docker will use a soft limitation.
* `cpu_shares` - (Optional, int) CPU shares (relative weight) for the container.
* `cpuset` - (Optional, string) A comma-separated list or hyphen-separated range of CPUs a container can use.
* `log_driver` - (Optional, string) The logging driver to use for the container.
Defaults to "json-file".
* `log_opts` - (Optional, map of strings) Key/value pairs to use as options for