diff --git a/examples/templates/docker-image-builds/main.tf b/examples/templates/docker-image-builds/main.tf index 35e0184399..75ca25a7a9 100644 --- a/examples/templates/docker-image-builds/main.tf +++ b/examples/templates/docker-image-builds/main.tf @@ -38,9 +38,20 @@ variable "step2_arch" { } sensitive = true } +variable "step3_OS" { + description = <<-EOF + What operating system is your Coder host on? + EOF + + validation { + condition = contains(["MacOS", "Windows", "Linux"], var.step3_OS) + error_message = "Value must be MacOS, Windows, or Linux." + } + sensitive = true +} provider "docker" { - host = "unix:///var/run/docker.sock" + host = var.step3_OS == "Windows" ? "npipe:////.//pipe//docker_engine" : "unix:///var/run/docker.sock" } provider "coder" { diff --git a/examples/templates/docker/main.tf b/examples/templates/docker/main.tf index 8fb124aa8f..f1f7e689b3 100644 --- a/examples/templates/docker/main.tf +++ b/examples/templates/docker/main.tf @@ -17,8 +17,6 @@ terraform { # host on the "docker" provider below. variable "step1_docker_host_warning" { description = <<-EOF - Is Docker running on the Coder host? - This template will use the Docker socket present on the Coder host, which is not necessarily your local machine. @@ -45,10 +43,22 @@ variable "step2_arch" { } sensitive = true } +variable "step3_OS" { + description = <<-EOF + What operating system is your Coder host on? + EOF + + validation { + condition = contains(["MacOS", "Windows", "Linux"], var.step3_OS) + error_message = "Value must be MacOS, Windows, or Linux." + } + sensitive = true +} provider "docker" { - host = "unix:///var/run/docker.sock" + host = var.step3_OS == "Windows" ? "npipe:////.//pipe//docker_engine" : "unix:///var/run/docker.sock" } + provider "coder" { }