Docker API调用返回“服务器向HTTPS客户端提供了HTTP响应”

I have the following Code and a Call to the API returns an error as follows, I hve also pasted Docker Daemon command below. I have tried a few combinations from HTTP/ HTTPS / TCP with / without TLS.

Where could I be wrong here?

"panic: An error occurred trying to connect: Get https://172.28.8.212:2375/v1.24/containers/json?limit=0: http: server gave HTTP response to HTTPS client "

func main() {
    var headers map[string]string

    tr := &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    }

    cl := &http.Client{Timeout: time.Minute}

    cli, err := client.NewClient("tcp://172.28.8.212:2375", "1.24", cl, headers)
    if err != nil {
        panic(err)
    }

    containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
    if err != nil {
        panic(err)
    }

    for _, container := range containers {
        fmt.Printf("%s %s
", container.ID[:10], container.Image)
    }
}

My Docker Daemon is started as follows

[Unit]
Description = Docker Service Daemon
[Service]
ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store=consul://172.28.8.211:8500
查看全部
dream2891
dream2891
2016/11/14 22:21
  • containers
  • docker
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复