mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-01-05 14:29:38 -05:00
Add the networks entry
This commit is contained in:
parent
94b54c2a30
commit
99f83853f7
2 changed files with 14 additions and 0 deletions
|
|
@ -238,6 +238,12 @@ func resourceDockerContainer() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"networks": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue