Merge branch 'sunthera/d-cpuset-added'

This commit is contained in:
Manuel Vogel 2018-10-28 09:13:03 +01:00
commit bb16358a7a
No known key found for this signature in database
GPG key ID: 533006C7B61DB1CE
5 changed files with 18 additions and 0 deletions

View file

@ -5,6 +5,7 @@ IMPROVEMENTS
* Adds `rm` and `attach` options to execute short-lived containers [GH-43] and [[#106](https://github.com/terraform-providers/terraform-provider-docker/pull/106)]
* Adds container healthcheck[[#93](https://github.com/terraform-providers/terraform-provider-docker/pull/93)]
* Adds the docker container start flag [GH-62] and [[#94](https://github.com/terraform-providers/terraform-provider-docker/pull/94)]
* Adds `cpu_set` to docker container [[#41](https://github.com/terraform-providers/terraform-provider-docker/pull/41)]
BUG FIXES
* Fixes that new network were appended to the default bridge [GH-10]

View file

@ -426,6 +426,13 @@ func resourceDockerContainer() *schema.Resource {
ValidateFunc: validateIntegerGeqThan(0),
},
"cpu_set": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validateStringMatchesPattern(`^\d+([,-]\d+)*$`),
},
"log_driver": &schema.Schema{
Type: schema.TypeString,
Optional: true,

View file

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

View file

@ -212,6 +212,10 @@ func TestAccDockerContainer_customized(t *testing.T) {
return fmt.Errorf("Container has wrong cpu shares setting: %d", c.HostConfig.CPUShares)
}
if c.HostConfig.CpusetCpus != "0-1" {
return fmt.Errorf("Container has wrong cpu set setting: %s", c.HostConfig.CpusetCpus)
}
if len(c.HostConfig.DNS) != 1 {
return fmt.Errorf("Container does not have the correct number of dns entries: %d", len(c.HostConfig.DNS))
}
@ -1048,6 +1052,7 @@ resource "docker_container" "foo" {
memory = 512
memory_swap = 2048
cpu_shares = 32
cpu_set = "0-1"
capabilities {
add= ["ALL"]

View file

@ -84,6 +84,7 @@ data is stored in them. See [the docker documentation][linkdoc] for more details
* `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.
* `cpu_set` - (Optional, string) A comma-separated list or hyphen-separated range of CPUs a container can use, e.g. `0-1`.
* `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