当前位置:   article > 正文

fabric在make docker时遇到的问题_package golang.org/x/tools/go/packages: unrecogniz

package golang.org/x/tools/go/packages: unrecognized import path "golang.org

在进行make docker时,最后出现如下错误:

  1. Building dockerized gotools
  2. make[1]: Entering directory '/opt/gopath/src/github.com/hyperledger/fabric'
  3. Building github.com/maxbrunsfeld/counterfeiter -> counterfeiter
  4. package golang.org/x/tools/go/packages: unrecognized import path "golang.org/x/tools/go/packages" (https fetch: Get https://golang.org/x/tools/go/packages?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
  5. package golang.org/x/tools/go/types/typeutil: unrecognized import path "golang.org/x/tools/go/types/typeutil" (https fetch: Get https://golang.org/x/tools/go/types/typeutil?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
  6. gotools.mk:59: recipe for target 'gotool.counterfeiter' failed
  7. make[1]: Leaving directory '/opt/gopath/src/github.com/hyperledger/fabric'
  8. gotools.mk:64: recipe for target '/opt/gotools/bin/counterfeiter' failed
  9. package golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
  10. make[1]: *** [gotool.counterfeiter] Error 1
  11. make: *** [/opt/gotools/bin/counterfeiter] Error 2
  12. make: *** [.build/docker/gotools] 错误 2

这是因为国内网无法直接访问https://golang.org/x/tools/go/网站。此时可以通过以下命令解决此问题:

  1. $ mkdir -p $GOPATH/src/golang.org/x/
  2. $ cd $GOPATH/src/golang.org/x/
  3. $ git clone https://github.com/golang/tools.git
  4. $ mkdir -p $GOPATH/src/github.com/maxbrunsfeld
  5. $ cd $GOPATH/src/github.com/maxbrunsfeld
  6. $ git clone https://github.com/maxbrunsfeld/counterfeiter.git
  7. $ go install ./counterfeiter

再次运行make docker,又出现了新的错误:

  1. ......
  2. Building docker tools-image
  3. docker build -t hyperledger/fabric-tools -f .build/image/tools/Dockerfile .
  4. Sending build context to Docker daemon 391.1 MB
  5. Step 1/14 : FROM hyperledger/fabric-baseimage:amd64-0.4.14 as builder
  6. Error parsing reference: "hyperledger/fabric-baseimage:amd64-0.4.14 as builder" is not a valid repository/tag: invalid reference format
  7. make: *** [.build/image/tools/.dummy-amd64-1.4.0-rc2-snapshot-b87ec80] 错误 1

通过这个错误可以看到,这个过程是要创建tools-image,使用的方法是docker build,使用的文件是Dockerfile,接下来错误发生在Dockerfile文件的第一条语句上,即FROM hyperledger/fabric-baseimage:amd64-0.4.14 as builder,而错误提示为:Error parsing reference: "hyperledger/fabric-baseimage:amd64-0.4.14 as builder" is not a valid repository/tag: invalid reference format,即这条语句的格式不对。。。查看dockerfile的官方文档发现确实有这个用法,只是as用的是大写AS,于是修改成大写AS再试一次。结果还是同样的错误。。。最后在网上看到,说FROM AS的语法是在Docker 17.05及以上版本新出来的指令,卧槽,赶紧查看docker版本,发现是1.13.1,看来有戏。那么接下来对docker进行升级。

首先列出包含docker字段的软件的信息

  1. [root@master1 fabric]# rpm -qa | grep docker
  2. docker-client-1.13.1-91.git07f3374.el7.centos.x86_64
  3. docker-common-1.13.1-91.git07f3374.el7.centos.x86_64
  4. docker-1.13.1-91.git07f3374.el7.centos.x86_64

接下来用yum remove删除这三个软件

[root@master1 fabric]# yum remove docker-client-1.13.1-91.git07f3374.el7.centos.x86_64
[root@master1 fabric]# yum remove docker-common-1.13.1-91.git07f3374.el7.centos.x86_64
[root@master1 fabric]# yum remove docker-1.13.1-91.git07f3374.el7.centos.x86_64

然后使用curl升级到最新版

[root@master1 fabric]# curl -fsSL https://get.docker.com/ | sh

接下来重启docker,并查看版本信息

  1. [root@master1 fabric]# systemctl restart docker
  2. [root@master1 fabric]# docker version

之后再次运行make docker就成功了! 

 

此外,在make docker的过程中还可能会出现以下问题:

  1. debconf: unable to initialize frontend: Dialog
  2. debconf: (TERM is not set, so the dialog frontend is not usable.)
  3. debconf: falling back to frontend: Readline
  4. debconf: unable to initialize frontend: Readline
  5. debconf: (This frontend requires a controlling tty.)
  6. debconf: falling back to frontend: Teletype
  7. dpkg-preconfigure: unable to re-open stdin:

虽然这个问题不影响程序的进一步运行,但还是解决掉为好。

原因是在使用apt-get安装依赖时,可能会有对话框,制作镜像时如果不处理对话框会导致失败,解决办法也很简单

在Dockerfile中增加一句:ENV DEBIAN_FRONTEND noninteractive即可(位置任意,但最好在出错语句之前设置)

 

还有一个问题如下:

  1. /tmp/go-build/cgo-gcc-prolog:49: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  2. (cd sampleconfig && tar -jc *) > .build/sampleconfig.tar.bz2
  3. tar (child): bzip2:无法 exec: 没有那个文件或目录
  4. tar (child): Error is not recoverable: exiting now
  5. make: *** [.build/sampleconfig.tar.bz2] 错误 141

原因是没有安装bzip2包,直接运行yum install -y bzip2安装即可。

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号