How to use TaskLogs endpoint of docker go-lang API?

78 views Asked by At

My actual question is, how to get specific version of go-lang docker client? The latest version I can find is v17.03.2-ce which is a year or older. I want to use docker 1.37 which has TaskLogs. But could not find one with this specific version. If I choose the master branch, this will give me v1.39 but my installed docker client API is v1.38 which throws error "Error response from daemon: client version 1.39 is too new. Maximum supported API version is 1.38".

Why I need v1.37? I was using v1.13.1, which was working fine. Now I need to implement TaskLogs grabber and this is not available in v1.13.1.

1

There are 1 answers

0
wannamit On

SOLVED

It was really simple:

In Gopkg.toml add:

[[constraint]]
  name = "github.com/docker/docker"
  branch = "master"

[[override]]
  name = "github.com/docker/distribution"
  branch = "master"

To use any version create the client with the specific version:

import (
    dockerClient "github.com/docker/docker/client"
    dockerTypes "github.com/docker/docker/api/types"
    )
var dockerClientInst *dockerClient.Client
dockerClient.NewClientWithOpts(dockerClient.WithVersion("1.37"))
responseBody, err := dockerClientInst.TaskLogs(ctx, taskID, dockerTypes.ContainerLogsOptions{})

That's it.