Merge pull request #1599 from hashicorp/1554-docker-network-settings

[repack] "Add docker container network settings to output attribute #1554"
This commit is contained in:
Paul Hinze 2015-04-20 15:29:45 -05:00
commit ff224dec13
3 changed files with 41 additions and 0 deletions

View File

@ -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,
},
},
}
}

View File

@ -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
}

View File

@ -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.