Add the networks entry

This commit is contained in:
Colin Hebert 2016-01-04 20:58:54 +01:00
parent 94b54c2a30
commit 99f83853f7
2 changed files with 14 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)