Docker在完成Golang项目构建之前退出

时间:2016-11-17 13:09:25

标签: go docker dockerfile

我正在尝试使用Docker构建一个Golang项目,但是该过程在完成之前一直存在,这里是终端输出的一部分:

github.com/kataras/go-template (download)
Fetching https://golang.org/x/crypto/acme/autocert?go-get=1
Parsing meta tags from https://golang.org/x/crypto/acme/autocert?go-get=1 (status code 200)
get "golang.org/x/crypto/acme/autocert": found meta tag main.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at https://golang.org/x/crypto/acme/autocert?go-get=1
get "golang.org/x/crypto/acme/autocert": verifying non-authoritative meta tag
The command '/bin/sh -c go get -v' returned a non-zero code: 1

我的Dockerfile看起来像这样:

FROM golang:1.7

RUN mkdir -p $GOPATH/src/bitbucket.org/cram/rolldrove
WORKDIR $GOPATH/src/bitbucket.org/cram/rolldrove

COPY . $GOPATH/src/bitbucket.org/cram/rolldrove

RUN go get -v
RUN go build ./server.go

CMD ["./server"]

请帮助,我该如何解决这个问题?它以前工作但后来开始发生。

修改

使用-x标志重新运行

github.com/kataras/go-template (download)
cd .
git clone https://github.com/kataras/go-template /go/src/github.com/kataras/go-template
cd /go/src/github.com/kataras/go-template
git submodule update --init --recursive
cd /go/src/github.com/kataras/go-template
git show-ref
cd /go/src/github.com/kataras/go-template
git submodule update --init --recursive
Fetching https://golang.org/x/crypto/acme/autocert?go-get=1
Parsing meta tags from https://golang.org/x/crypto/acme/autocert?go-get=1 (status code 200)
get "golang.org/x/crypto/acme/autocert": found meta tag main.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at https://golang.org/x/crypto/acme/autocert?go-get=1
get "golang.org/x/crypto/acme/autocert": verifying non-authoritative meta tag
The command '/bin/sh -c go get -v -x' returned a non-zero code: 1

问题似乎是这一行:

get "golang.org/x/crypto/acme/autocert": verifying non-authoritative meta tag

1 个答案:

答案 0 :(得分:1)

问题在于导入了其中一个软件包。

我开始删除并更换一次拉出的第三方软件包,然后在每个软件包之后进行构建。在我从Github中删除了一个用于生成uuid s的包后,它最终成功构建了。我最终使用了我here {{3}}的uuid生成器代码段。