mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-01-23 23:22:58 -05:00
fix: Check the operating system for determining the default Docker socket (#427)
Windows doesn't use `/var/run/docker.sock`, so this provider didn't work out of the box.
This commit is contained in:
parent
78e4a2bbe4
commit
6c8714dc4a
1 changed files with 12 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/user"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/cli/config/configfile"
|
||||
|
|
@ -39,9 +40,17 @@ func New(version string) func() *schema.Provider {
|
|||
p := &schema.Provider{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"host": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("DOCKER_HOST", "unix:///var/run/docker.sock"),
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: func() (interface{}, error) {
|
||||
if v := os.Getenv("DOCKER_HOST"); v != "" {
|
||||
return v, nil
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
return "npipe:////./pipe/docker_engine", nil
|
||||
}
|
||||
return "unix:///var/run/docker.sock", nil
|
||||
},
|
||||
Description: "The Docker daemon address",
|
||||
},
|
||||
"ssh_opts": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue