diff --git a/builtin/providers/docker/resource_docker_container.go b/builtin/providers/docker/resource_docker_container.go index de0b0b667..10481b268 100644 --- a/builtin/providers/docker/resource_docker_container.go +++ b/builtin/providers/docker/resource_docker_container.go @@ -116,6 +116,26 @@ func resourceDockerContainer() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: stringSetHash, }, + + "ip_address": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "ip_prefix_length": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "gateway": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "bridge": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/builtin/providers/docker/resource_docker_container_funcs.go b/builtin/providers/docker/resource_docker_container_funcs.go index ae0a6e6bd..c6bd9dea8 100644 --- a/builtin/providers/docker/resource_docker_container_funcs.go +++ b/builtin/providers/docker/resource_docker_container_funcs.go @@ -138,6 +138,14 @@ func resourceDockerContainerRead(d *schema.ResourceData, meta interface{}) error return resourceDockerContainerDelete(d, meta) } + // Read Network Settings + if container.NetworkSettings != nil { + d.Set("ip_address", container.NetworkSettings.IPAddress) + d.Set("ip_prefix_length", container.NetworkSettings.IPPrefixLen) + d.Set("gateway", container.NetworkSettings.Gateway) + d.Set("bridge", container.NetworkSettings.Bridge) + } + return nil } diff --git a/website/source/docs/providers/docker/r/container.html.markdown b/website/source/docs/providers/docker/r/container.html.markdown index ebeabaa00..d5a4c823e 100644 --- a/website/source/docs/providers/docker/r/container.html.markdown +++ b/website/source/docs/providers/docker/r/container.html.markdown @@ -77,3 +77,16 @@ the following: is coming from. * `read_only` - (Optinal, bool) If true, this volume will be readonly. Defaults to false. + +## Attributes Reference + +The following attributes are exported: + + * `ip_address` - The IP address of the container as read from its + NetworkSettings. + * `ip_prefix_length` - The IP prefix length of the container as read from its + NetworkSettings. + * `gateway` - The network gateway of the container as read from its + NetworkSettings. + * `bridge` - The network bridge of the container as read from its + NetworkSettings.