douchun1961
2019-03-11 17:38 阅读 66

是否可以在Docker中安装gopkg.in软件包?

I am trying to run golang application which use goracle library with such Dockerfile:

FROM golang:1.12

RUN go get github.com/gorilla/mux && \
  go get github.com/gorilla/handlers && \
  go get github.com/lib/pq && \
  go get github.com/joho/godotenv && \
  go get github.com/jinzhu/gorm && \
  go get gopkg.in/goracle.v2

ADD ./ /go/src/application

WORKDIR /go/src/application

RUN go build -o /bin application

ENV PORT=8000

CMD ["/bin"]

Unfortunatly it raise error when I try to create image:

package gopkg.in/goracle.v2: unrecognized import path "gopkg.in/goracle.v2" (https fetch: Get https://gopkg.in/goracle.v2?go-get=1: proxyconnect tcp: tls: first record does not look like a TLS handshake)
The command '/bin/sh -c go get github.com/gorilla/mux &&   go get github.com/gorilla/handlers &&   go get github.com/lib/pq &&   go get github.com/joho/godotenv &&   go get github.com/jinzhu/gorm &&   go get gopkg.in/goracle.v2' returned a non-zero code: 1

Why I can't install goracle library in Docker? How to fix this problem?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    du127953 du127953 2019-03-13 17:18

    In my case the CentOS server where was located Docker has proxy. For thats why I couldn't download the gopkg.in/goracle.v2 package.

    SOLUTION:

    1) Create vender folder inside your project.

    2) Remove source code of gopkg.in/goracle.v2 package which you has in go/src folder to vender folder.

    3) Run you Dockerfile.

    In my case this instruction removed problem with importing of gopkg.in/goracle.v2 package.

    I hope this post will helpful for somebody!

    点赞 评论 复制链接分享

相关推荐