Add the networks entry

This commit is contained in:
Colin Hebert 2016-01-04 20:58:54 +01:00
parent f09280891c
commit 6e36095644
3 changed files with 15 additions and 0 deletions

View File

@ -238,6 +238,12 @@ func resourceDockerContainer() *schema.Resource {
Optional: true,
ForceNew: true,
},
"networks": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
},
},
}
}

View File

@ -148,6 +148,14 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
d.SetId(retContainer.ID)
if v, ok := d.GetOk("networks"); ok {
connectionOpts := &dc.NetworkConnectionOptions{Container: retContainer.ID}
for _, network := range v.(*schema.Set).List() {
client.ConnectNetwork(network.(string), connectionOpts)
}
}
creationTime = time.Now()
if err := client.StartContainer(retContainer.ID, hostConfig); err != nil {
return fmt.Errorf("Unable to start container: %s", err)

View File

@ -68,6 +68,7 @@ The following arguments are supported:
Defaults to "json-file".
* `log_opts` - (Optional) Key/value pairs to use as options for the logging
driver.
* `networks` - (Optional, set of strings) Id of the networks in which the container is.
<a id="ports"></a>
## Ports