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

huangapple go评论89阅读模式
英文:

Docker Exits Before Completing Golang Project Build

问题

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

github.com/kataras/go-template (下载)
正在获取 https://golang.org/x/crypto/acme/autocert?go-get=1
正在解析 https://golang.org/x/crypto/acme/autocert?go-get=1 的元标签(状态码 200)
在 https://golang.org/x/crypto/acme/autocert?go-get=1 找到 meta 标签 main.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"}
获取 "golang.org/x/crypto/acme/autocert":正在验证非权威的 meta 标签
命令 '/bin/sh -c go get -v' 返回了非零代码: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 (下载)
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
正在获取 https://golang.org/x/crypto/acme/autocert?go-get=1
正在解析 https://golang.org/x/crypto/acme/autocert?go-get=1 的元标签(状态码 200)
在 https://golang.org/x/crypto/acme/autocert?go-get=1 找到 meta 标签 main.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"}
获取 "golang.org/x/crypto/acme/autocert":正在验证非权威的 meta 标签
命令 '/bin/sh -c go get -v -x' 返回了非零代码:1

问题似乎出在这一行:

获取 "golang.org/x/crypto/acme/autocert":正在验证非权威的 meta 标签
英文:

I'm trying to build a Golang project using Docker but the process keeps exiting before it completes, here's a part of the output from the terminal:

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

My Dockerfile look like this:

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"]

Help please, how do I fix this it? It was working before but then this started happening.

edit

Re-run with -x flag

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

The problem seems to be this line:

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

答案1

得分: 1

问题出在其中一个导入的包上。

我开始逐个删除和替换第三方包,每次删除一个后进行构建。最终,在我从Github上删除了一个用于生成uuid的包之后,构建成功了。我最终使用了我在这里找到的uuid生成器代码片段。

英文:

The problem was with one of the packages being imported.

I started removing and replacing the 3rd party packages being pulled in one at a time, doing a build after each. It eventually had a successful build after I removed a package from Github that I was using to generate uuids. I ended up using the uuid generator snippet I found here.

huangapple
  • 本文由 发表于 2016年11月17日 21:09:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/40655796.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定