fabric在make docker时遇到的问题

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

Building dockerized gotools
make[1]: Entering directory '/opt/gopath/src/github.com/hyperledger/fabric'
Building github.com/maxbrunsfeld/counterfeiter -> counterfeiter
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)
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)
gotools.mk:59: recipe for target 'gotool.counterfeiter' failed
make[1]: Leaving directory '/opt/gopath/src/github.com/hyperledger/fabric'
gotools.mk:64: recipe for target '/opt/gotools/bin/counterfeiter' failed
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)
make[1]: *** [gotool.counterfeiter] Error 1
make: *** [/opt/gotools/bin/counterfeiter] Error 2
make: *** [.build/docker/gotools] 错误 2

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

$ mkdir -p $GOPATH/src/golang.org/x/
$ cd $GOPATH/src/golang.org/x/
$ git clone https://github.com/golang/tools.git
$ mkdir -p $GOPATH/src/github.com/maxbrunsfeld
$ cd $GOPATH/src/github.com/maxbrunsfeld
$ git clone https://github.com/maxbrunsfeld/counterfeiter.git
$ go install ./counterfeiter

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

......
Building docker tools-image
docker build  -t hyperledger/fabric-tools -f .build/image/tools/Dockerfile .
Sending build context to Docker daemon 391.1 MB
Step 1/14 : 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
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字段的软件的信息

[root@master1 fabric]# rpm -qa | grep docker
docker-client-1.13.1-91.git07f3374.el7.centos.x86_64
docker-common-1.13.1-91.git07f3374.el7.centos.x86_64
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,并查看版本信息

[root@master1 fabric]# systemctl restart docker
[root@master1 fabric]# docker version

fabric在make docker时遇到的问题_第1张图片

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

fabric在make docker时遇到的问题_第2张图片

 

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

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

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

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

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

 

还有一个问题如下:

/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
(cd sampleconfig && tar -jc *) > .build/sampleconfig.tar.bz2
tar (child): bzip2:无法 exec: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
make: *** [.build/sampleconfig.tar.bz2] 错误 141

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

你可能感兴趣的:(linux,VMware,区块链,hyperleger,fabric,docker)