Skip to content

Commit 7ad68ca

Browse files
authored
example: docker: support Windows hosts (#1880)
1 parent da7ed8b commit 7ad68ca

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

examples/templates/docker-image-builds/main.tf

+12-1
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,20 @@ variable "step2_arch" {
3838
}
3939
sensitive = true
4040
}
41+
variable "step3_OS" {
42+
description = <<-EOF
43+
What operating system is your Coder host on?
44+
EOF
45+
46+
validation {
47+
condition = contains(["MacOS", "Windows", "Linux"], var.step3_OS)
48+
error_message = "Value must be MacOS, Windows, or Linux."
49+
}
50+
sensitive = true
51+
}
4152

4253
provider "docker" {
43-
host = "unix:///var/run/docker.sock"
54+
host = var.step3_OS == "Windows" ? "npipe:////.//pipe//docker_engine" : "unix:///var/run/docker.sock"
4455
}
4556

4657
provider "coder" {

examples/templates/docker/main.tf

+13-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ terraform {
1717
# host on the "docker" provider below.
1818
variable "step1_docker_host_warning" {
1919
description = <<-EOF
20-
Is Docker running on the Coder host?
21-
2220
This template will use the Docker socket present on
2321
the Coder host, which is not necessarily your local machine.
2422
@@ -45,10 +43,22 @@ variable "step2_arch" {
4543
}
4644
sensitive = true
4745
}
46+
variable "step3_OS" {
47+
description = <<-EOF
48+
What operating system is your Coder host on?
49+
EOF
50+
51+
validation {
52+
condition = contains(["MacOS", "Windows", "Linux"], var.step3_OS)
53+
error_message = "Value must be MacOS, Windows, or Linux."
54+
}
55+
sensitive = true
56+
}
4857

4958
provider "docker" {
50-
host = "unix:///var/run/docker.sock"
59+
host = var.step3_OS == "Windows" ? "npipe:////.//pipe//docker_engine" : "unix:///var/run/docker.sock"
5160
}
61+
5262
provider "coder" {
5363
}
5464

0 commit comments

Comments
 (0)