Skip to content

Commit fd3ae2d

Browse files
committed
Catch potential custom network errors in docker
1 parent 8ca660d commit fd3ae2d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

builtin/providers/docker/resource_docker_container_funcs.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
162162
if v, ok := d.GetOk("networks"); ok {
163163
connectionOpts := dc.NetworkConnectionOptions{Container: retContainer.ID}
164164

165-
for _, network := range v.(*schema.Set).List() {
166-
client.ConnectNetwork(network.(string), connectionOpts)
165+
for _, rawNetwork := range v.(*schema.Set).List() {
166+
network := rawNetwork.(string)
167+
if err := client.ConnectNetwork(network), connectionOpts); err != nil {
168+
return fmt.Errorf("Unable to connect to network '%s': %s", network, err)
169+
}
167170
}
168171
}
169172

0 commit comments

Comments
 (0)