diff --git a/docker/resource_docker_container.go b/docker/resource_docker_container.go index 4a73495f..778aecb9 100644 --- a/docker/resource_docker_container.go +++ b/docker/resource_docker_container.go @@ -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, + }, }, } } diff --git a/docker/resource_docker_container_funcs.go b/docker/resource_docker_container_funcs.go index b914b216..0707bd23 100644 --- a/docker/resource_docker_container_funcs.go +++ b/docker/resource_docker_container_funcs.go @@ -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 diff --git a/docker/resource_docker_container_test.go b/docker/resource_docker_container_test.go index cbade28a..3c2c753c 100644 --- a/docker/resource_docker_container_test.go +++ b/docker/resource_docker_container_test.go @@ -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" } diff --git a/website/docs/r/container.html.markdown b/website/docs/r/container.html.markdown index 95a62abd..b940b234 100644 --- a/website/docs/r/container.html.markdown +++ b/website/docs/r/container.html.markdown @@ -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:` or `host`. ### Capabilities