Merge pull request #4918 from ColinHebert/docker_network_error

provider/docker: Catch potential custom network errors in docker
This commit is contained in:
James Nugent 2016-01-30 17:17:29 -05:00
commit e490b44daa
1 changed files with 5 additions and 2 deletions

View File

@ -162,8 +162,11 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
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)
for _, rawNetwork := range v.(*schema.Set).List() {
network := rawNetwork.(string)
if err := client.ConnectNetwork(network, connectionOpts); err != nil {
return fmt.Errorf("Unable to connect to network '%s': %s", network, err)
}
}
}