Пример #1
0
// Reads DOCKER_HOST environment variable
// If it's empty, it validates and returns default docker endpoint
func getDockerEndPoint() (dep string, err error) {
	dockerHost := os.Getenv("DOCKER_HOST")
	if dockerHost != "" {
		dep = dockerHost
		return dep, nil
	}
	return docker.DefaultDockerHost()
}
Пример #2
0
// dockerClient creates *docker.Client. In test / dev mode we can use ENV vars
// to connect to the docker daemon. In production mode we will read
// docker.endpoint from the config file.
func (d *DockerDriver) dockerClient() (*docker.Client, error) {
	// In dev mode, read DOCKER_* environment variables DOCKER_HOST,
	// DOCKER_TLS_VERIFY, and DOCKER_CERT_PATH. This allows you to run tests and
	// demo against boot2docker or a VM on OSX and Windows. This falls back on
	// the default unix socket on linux if tests are run on linux.
	//
	// Also note that we need to turn on DevMode in the test configs.
	if d.config.DevMode {
		return docker.NewClientFromEnv()
	}

	// In prod mode we'll read the docker.endpoint configuration and fall back
	// on the host-specific default. We do not read from the environment.
	defaultEndpoint, err := docker.DefaultDockerHost()
	if err != nil {
		return nil, fmt.Errorf("Unable to determine default docker endpoint: %s", err)
	}
	dockerEndpoint := d.config.ReadDefault("docker.endpoint", defaultEndpoint)

	return docker.NewClient(dockerEndpoint)
}