Skip to content

Commit 395ea26

Browse files
committed
Use default cert dir for oc cluster up client if DOCKER_TLS_VERIFY is set
1 parent 6f7e2fd commit 395ea26

File tree

1 file changed

+12
-2
lines changed
  • pkg/bootstrap/docker

1 file changed

+12
-2
lines changed

pkg/bootstrap/docker/up.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"runtime"
1010

1111
"github.com/blang/semver"
12+
"github.com/docker/docker/pkg/homedir"
1213
dockerclient "github.com/docker/engine-api/client"
1314
docker "github.com/fsouza/go-dockerclient"
1415
"github.com/golang/glog"
@@ -423,10 +424,19 @@ func getDockerClient(out io.Writer, dockerMachine string, canStartDockerMachine
423424
return dockerClient, engineAPIClient, nil
424425
}
425426

427+
dockerTLSVerify := os.Getenv("DOCKER_TLS_VERIFY")
428+
dockerCertPath := os.Getenv("DOCKER_CERT_PATH")
429+
if len(dockerTLSVerify) > 0 && len(dockerCertPath) == 0 {
430+
home := homedir.Get()
431+
if home == "" {
432+
return nil, nil, errors.NewError("environment variable HOME must be set if DOCKER_CERT_PATH is not set")
433+
}
434+
dockerCertPath = filepath.Join(home, ".docker")
435+
os.Setenv("DOCKER_CERT_PATH", dockerCertPath)
436+
}
437+
426438
if glog.V(4) {
427439
dockerHost := os.Getenv("DOCKER_HOST")
428-
dockerTLSVerify := os.Getenv("DOCKER_TLS_VERIFY")
429-
dockerCertPath := os.Getenv("DOCKER_CERT_PATH")
430440
if len(dockerHost) == 0 && len(dockerTLSVerify) == 0 && len(dockerCertPath) == 0 {
431441
glog.Infof("No Docker environment variables found. Will attempt default socket.")
432442
}

0 commit comments

Comments
 (0)