Skip to content

Unable to use some of the docker API due to vendoring issues #29362

Closed

Description

@jeffw-wherethebitsroam

Description

I am trying to use version 1.13.0-rc3 of the docker api for golang. My imports are:

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"

I am unable to create a HostConfig like:

portBindings := make(nat.PortMap)
var ulimits []*units.Ulimit
hostConfig := &container.HostConfig{
		PortBindings: portBindings,
		Resources: container.Resources{
			Ulimits: ulimits,
		},
	}

Due to the errors:

cannot use portBindings (type "github.com/docker/go-connections/nat".PortMap) as type "github.com/docker/docker/vendor/github.com/docker/go-connections/nat".PortMap in field value

cannot use ulimits (type []*"github.com/docker/go-units".Ulimit) as type []*"github.com/docker/docker/vendor/github.com/docker/go-units".Ulimit in field value

I cannot use the vendored versions, so how can I get around this?

Steps to reproduce the issue:

  1. Try to create a container.HostConfig using github.com/docker/go-connections/nat.PortMap or github.com/docker/go-units.Ulimit

Describe the results you received:
Failed to compile

Describe the results you expected:
Compile

Activity

  1. tamird commented on Dec 13, 2016

    @tamird

    This was introduced in #27912 (comment) and a fix was previously attempted in #28080, which was closed without explanation.

    cc @LK4D4

  2. vdemeester commented on Dec 13, 2016

    @vdemeester
    Member

    Quoting @dnephin on this as I do agree with him.

    If you're using docker/docker as a dependency to your project you should manage your dependencies using a tool like vndr or glide. You shouldn't rely on the vendor/ directory in this project.

    The workaround is to remove the vendor/ folder of the docker/docker after getting it. It's a little bit tricky depending on what you are using to manage your dependencies though.

    And as @tiborvass said

    Hopefully we'll find a solution as part of the ongoing works in the Go world.

  3. tamird commented on Dec 13, 2016

    @tamird
  4. vdemeester commented on Dec 13, 2016

    @vdemeester
    Member

    @tamird I do agree it's not the best. It's just the current workaround, and I really wish we could somehow make it work. Having a vendor folder is a huge enhancement on the development on docker/docker itself as we don't rely on some autopath hack anymore but it broke users of the client side.

    Still looking at some possible ideas like extracting the client client.APIClient to a repository for each tagged version of docker (i.e. any RC and GA releases) or something else.

  5. jeffw-wherethebitsroam commented on Dec 14, 2016

    @jeffw-wherethebitsroam
    Author

    Agreeing with @tamird here that it would be really great if the API client could be returned to it's own repository and be vendored into docker/docker along with all of the other dependencies.

    A couple of other alternatives:

    • the API client does not expose any of the vendored types directly.
    • the docker/docker project uses a tool like glide and does not actually store the vendor directory in the git repository, but installs them at build time.

    For what its worth, I am using glide for dependencies, but that doesn't resolve the issue by itself, just makes for more interesting error messages. I've now added:

    glide install --strip-vendor
    

    As part of my 'dependencies' make target. But it just feels a little dirty. Works for now though.

  6. ds0nt commented on Jan 12, 2017

    @ds0nt

    Well then... wow.

  7. CpuID commented on Jul 20, 2018

    @CpuID

    Any movement on this? It's still in a pretty nasty state :(

    I went to use a project I wrote back a year or two ago, to find something was busted between the N docker repos + the various vendor dirs in each of them.

    Example:

    cannot use index (type *"github.com/docker/docker/api/types/registry".IndexInfo) as type *"github.com/docker/cli/vendor/github.com/docker/docker/api/types/registry".IndexInfo in argument to command.ResolveAuthConfig
    
  8. CpuID commented on Jul 20, 2018

    @CpuID

    I think I worked around my issues for now, by going:

    cd GOPATH/src/github.com/docker
    rm -rf docker/vendor
    rm -rf cli/vendor
    rm -rf distribution/vendor
    

    And then ensured my version of cobra/spf13 + cobra/pflag were up to date. Not elegant, but technically works around my issues.

  9. Xjs commented on Sep 6, 2018

    @Xjs

    This totally breaks depending on docker/docker from Bazel build files (need to fork each and every docker repository and remove the vendor directories, and rebase to keep in sync), since https://github.com/bazelbuild/bazel-gazelle cannot ignore vendor directories for dependencies. Are there any plans to remove the vendor directory (especially in the light of Go modules)?

  10. zscole commented on Jan 31, 2019

    @zscole

    Just wanted to chime in here, several years later, that this is still a recurring and prevalent issue. My existing workaround was deleting the vendor folder, but this is entirely impractical and absurd. Currently trying to solve the issue with go deps. Life is pain.

  11. B-Lukas commented on Apr 21, 2019

    @B-Lukas

    I am currently also stuck with this. It's very frustrating trying to get it to work with vendoring in a Pipeline

  12. rach-id commented on Jul 26, 2020

    @rach-id

    Any update on this ?

  13. akerouanton commented on Jul 26, 2020

    @akerouanton
    Member

    @sweexordious You can take a look at this comment from @thaJeztah, he explains what procedure should be followed to get it work with go mod 😉

  14. thaJeztah commented on Jul 26, 2020

    @thaJeztah
    Member

    This issue was related to the original change to switch to use vendor/ as the path for vendoring, which is the standard path for vendored dependencies. The solution for that is to use a vendoring tool that strips nested dependencies (or to configure the tool you're using to do so).

    Unfortunately, using go modules with this repository is still difficult (and complicated to resolve). There are some newer issues that discuss this, and which are more current. Let me close this one in favour of those, and link to some comments on those that may be helpful #39056 (#39056 (comment)) and #39302 (#39302 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions