diff --git a/builtin/providers/docker/resource_docker_container_funcs.go b/builtin/providers/docker/resource_docker_container_funcs.go index 39d2c09f0..0f276b0f6 100644 --- a/builtin/providers/docker/resource_docker_container_funcs.go +++ b/builtin/providers/docker/resource_docker_container_funcs.go @@ -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) + } } }