feat: add container ipc mode. (#182)

Closes #12
This commit is contained in:
Manuel Vogel 2019-09-23 20:11:59 +02:00 committed by GitHub
parent 42031f27fb
commit 36567a2a9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 0 deletions

View file

@ -722,6 +722,12 @@ func resourceDockerContainer() *schema.Resource {
Optional: true,
ForceNew: true,
},
"ipc_mode": {
Type: schema.TypeString,
Description: "IPC sharing mode for the container",
Optional: true,
ForceNew: true,
},
},
}
}

View file

@ -308,6 +308,9 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
if v, ok := d.GetOk("sysctls"); ok {
hostConfig.Sysctls = mapTypeMapValsToString(v.(map[string]interface{}))
}
if v, ok := d.GetOk("ipc_mode"); ok {
hostConfig.IpcMode = container.IpcMode(v.(string))
}
var retContainer container.ContainerCreateCreatedBody

View file

@ -455,6 +455,10 @@ func TestAccDockerContainer_customized(t *testing.T) {
return fmt.Errorf("Container doesn't have a correct working dir")
}
if c.HostConfig.IpcMode != "private" {
return fmt.Errorf("Container doesn't have a correct ipc mode")
}
return nil
}
@ -1435,6 +1439,7 @@ resource "docker_container" "foo" {
pid_mode = "host"
userns_mode = "testuser:231072:65536"
ipc_mode = "private"
working_dir = "/tmp"
}

View file

@ -107,6 +107,7 @@ data is stored in them. See [the docker documentation][linkdoc] for more details
* `userns_mode` - (Optional, string) Sets the usernamespace mode for the container when usernamespace remapping option is enabled.
* `healthcheck` - (Optional, block) See [Healthcheck](#healthcheck-1) below for details.
* `sysctls` - (Optional, map) A map of kernel parameters (sysctls) to set in the container.
* `ipc_mode` - (Optional, string) IPC sharing mode for the container. Possible values are: `none`, `private`, `shareable`, `container:<name|id>` or `host`.
<a id="capabilities-1"></a>
### Capabilities