Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official client semi broken #784

Closed
eyJhb opened this issue Jun 18, 2019 · 4 comments
Closed

Official client semi broken #784

eyJhb opened this issue Jun 18, 2019 · 4 comments

Comments

@eyJhb
Copy link
Contributor

eyJhb commented Jun 18, 2019

Just wanted to point up, that the most basic of features are broken in the official client, and should be noted.. Hence the reason for sticking with this library, see here - moby/moby#28269

Even this simple port code won't work.

package main

import (
	"context"
	"log"

	"github.com/docker/docker/api/types"
	docker "github.com/docker/docker/client"
	"github.com/docker/go-connections/nat"
)

func main() {
	ctx := context.TODO()
	// init stuff
	cli, err := docker.NewClientWithOpts()
	if err != nil {
		log.Fatal(err)
	}

	cli.NegotiateAPIVersion(ctx)

	// make container config
	var conf types.ContainerCreateConfig

	_, portBindings, err := nat.ParsePortSpecs([]string{"8080:8080/tcp"})
	if err != nil {
		log.Fatal(err)
	}

	portmap := nat.PortMap(portBindings)

	conf.HostConfig.PortBindings = portmap
}

Maybe this should be noted?

@fsouza
Copy link
Owner

fsouza commented Jun 18, 2019

Yikes I wasn't aware of that issue. On a plus side, once docker/docker migrates to go modules, this issue should be resolved. Until then, users will need to continue stripping the vendor directory, as docker mixes the main package & library packages in the same repo.

@eyJhb thanks for pointing that out. I'll amend the note in the README to mention potential shortcomings with the official SDK and vendoring.

@fsouza fsouza closed this as completed in de6696e Jun 18, 2019
@eyJhb
Copy link
Contributor Author

eyJhb commented Jun 21, 2019

Hoping it will happen, but I just see no mention for it. And the issue is pretty dated...

But thanks for the quick response @fsouza ! Really appreciate it, and great work on this client for go ;) Will continue to use it, seeing as it works better than the official.

@eyJhb
Copy link
Contributor Author

eyJhb commented May 28, 2022

It seems to work fine now @fsouza , I think it can be removed from the readme.md now :)

EDIT: At least the above code builds.

@fsouza
Copy link
Owner

fsouza commented May 28, 2022

It seems to work fine now @fsouza , I think it can be removed from the readme.md now :)

Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants