Skip to content

Instantly share code, notes, and snippets.

@rasouli
Created August 23, 2017 17:58
Show Gist options
  • Save rasouli/e2a01b329af2809910a9a47d6a050868 to your computer and use it in GitHub Desktop.
Save rasouli/e2a01b329af2809910a9a47d6a050868 to your computer and use it in GitHub Desktop.
installing docker client while the process of renaming "docker/docker" to "moby/moby" import path is in progress.
# while import path in docker project is being renamed to moby/moby,
# I had trouble installing/building moby client. I faced the following error on issuing
# $ go install
# command inside $GOPATH/src/github.com/moby/moby/client:
# ./service_create.go:96: cannot use distributionInspect.Descriptor.Digest (type "github.com/docker/docker/vendor/github.com/opencontainers/go-digest".Digest) as type "github.com/moby/moby/vendor/github.com/opencontainers/go-digest".Digest in argument to imageWithDigestString
# the workaround I found for time being is the following which helped me to compile the docker/moby client
# library, hope it comes useful.
# in order issue following command or similar for your platform:
# 1- issue go get to get the packages ( ignore the "no buildable Go source files in" error in the end)
go get -u -v github.com/moby/moby/
# 2- change your working directory to: $GOPATH/src/github.com/moby/moby/client
cd $GOPATH/src/github.com/moby/moby/client && go get .
#Explaination for above: as github.com/docker/docker redirects to the github.com/moby/moby "go get" will automatically create
#import path docker/docker for us, hence exact clone us of github.com/moby/moby is now created under github.com/docker/docker
#in go path (yeah let the go do the work for us...)
# 3- remove the following vendor packages in order to build docker client:
rm -rf $GOPATH/src/github.com/docker/docker/vendor/github.com/opencontainers/go-digest && rm -rf $GOPATH/src/github.com/moby/moby/vendor/github.com/opencontainers/go-digest
# 4- install go-digest:
go get -u -v github.com/opencontainers/go-digest && cd $GOPATH/src/github.com/opencontainers/go-digest && go install
# 5- continue installing and building the client
cd $GOPATH/src/github.com/moby/moby/client && go install
# 6- test to see if everything works:
go run my_docker_images.go
# the file will print some junk image IDs of current images on your machine.
package main
import (
"context"
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
func main() {
cli, err := client.NewEnvClient()
if err != nil {
panic(err)
}
images, err := cli.ImageList(context.Background(), types.ImageListOptions{})
if err != nil {
panic(err)
}
for _, img := range images {
fmt.Printf("Image : %s\n", img.ID)
}
}
@smithjessk
Copy link

This worked for me. Thanks!

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