From 1c68029ce903b6500ac267e95fcb912eb9b8622e Mon Sep 17 00:00:00 2001 From: Seb Patane Date: Thu, 7 Mar 2019 20:15:42 +1100 Subject: [PATCH] Normalize a blank string to 0.0.0.0 (#128) Works around a problem in Windows on Docker, which doesn't support providing an IP to to bind to for ports --- docker/resource_docker_container.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docker/resource_docker_container.go b/docker/resource_docker_container.go index 622238a9..37a316bf 100644 --- a/docker/resource_docker_container.go +++ b/docker/resource_docker_container.go @@ -253,6 +253,14 @@ func resourceDockerContainer() *schema.Resource { Default: "0.0.0.0", Optional: true, ForceNew: true, + StateFunc: func(val interface{}) string { + // Empty IP assignments default to 0.0.0.0 + if val.(string) == "" { + return "0.0.0.0" + } + + return val.(string) + }, }, "protocol": &schema.Schema{