我是 docker 新手,正在尝试为一个简单的 Go 应用程序制作一个 docker 容器。我正在使用 Godep 进行依赖管理。
这是我的 Dockerfile:
FROM pottava/golang:1.5
RUN go get github.com/tools/godep \
&& rm -rf /go/pkg /go/src
ADD ./ /go
ENV GOPATH /go
RUN godep go build -v -o ./bin/main ./src/main.go
当我尝试构建映像时,出现以下错误:
...
---> 5cb6dd001eb3
Removing intermediate container 15eb0b298adb
Step 5 : ENV GOPATH /go
---> Running in 1c0043c3e963
---> 6cd0498af200
Removing intermediate container 1c0043c3e963
Step 6 : RUN godep go build -v -o ./bin/main ./src/main.go
---> Running in af2386d13c9a
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]: Current Directory: /go
godep: [WARNING]: $GOPATH: /go
src/main.go:18:2: cannot find package "github.com/Sirupsen/logrus" in any of:
/usr/local/go/src/github.com/Sirupsen/logrus (from $GOROOT)
/go/Godeps/_workspace/src/github.com/Sirupsen/logrus (from $GOPATH)
/go/src/github.com/Sirupsen/logrus
...