实例化链码时出错

Please help me this issue, error happened when I instantiate my chaincode:

Currently, I guess the issue related to shim package, because I remove it in my utils package, instantiate successfully.

MyChainCode:

import (
    "bytes"
    "encoding/hex"
    "encoding/json"
    "fmt"
    "strconv"

    "github.com/golang/protobuf/proto"
    "github.com/hyperledger/fabric/core/chaincode/shim"
    "github.com/hyperledger/fabric/protos/msp"
    pb "github.com/hyperledger/fabric/protos/peer"
    "github.com/myproj/models"
    "github.com/myproj/packages/utils"
)

APIstub shim.ChaincodeStubInterface
...
username, _ = utils.GetCurrentUser(APIstub)
...

My packages

package utils

import (
    "github.com/hyperledger/fabric/core/chaincode/shim"
    "golang.org/x/crypto/bcrypt"
)

func GetCurrentUser(stub shim.ChaincodeStubInterface) (string, error) {
    cert, err := GetCreatorCert(stub)

    return cert.Subject.CommonName, err
}

Issue:

Error: Error endorsing chaincode: rpc error: code = Unknown desc = error starting container: Failed to generate platform-specific docker build: Error returned from build: 2 "# ~vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive ~vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:364:5: hdr.Format undefined (type *tar.Header has no field or method Format) ~vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:364:15: undefined: tar.FormatPAX ~/vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:1166:7: hdr.Format undefined (type *tar.Header has no field or method Format) ~/vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:1166:17: undefined: tar.FormatPAX

Fabric ver 1.1.0

Go ver 1.9.2

That can be because you have old version in some files inside your hyperledger/fabric folder.

If you are following the chaincode tutorial, you can just remove your hyperledger/fabric folder.

Regards

I had the same issue by following the documentation. Switching to branch 'release-1.1' solves the issue.

After cloning the repository proceed with:

hyperleger$ cd fabric
hyperledger/fabric$ git fetch
hyperledger/fabric$ git checkout release-1.1

I faced the same problem after upgrading fabric to 1.2.0. Fabric 1.2.0 requires go 1.10.x. So I upgraded go lang to 1.10.3 and it worked like a charm.