drbuowqe02101 2017-05-26 21:43
浏览 1229

docker-compose找不到软件包

I'm writing a simple app in GO and I have this folder structure

enter image description here

The docker-compose.yml file content is:

version: '2'
services:
  db:
    image: rethinkdb:latest
    ports:
      - "38080:8080"
      - "38015:28015"
      - "39015:29015"
  api:
    image: golang:1.8-alpine
    volumes:
      - .:/go/src/test_server/
    working_dir: /go/src/test_server
    command: go run server.go
    container_name: test_server
    ports:
      - "8085:8085"
    links:
      - db
    tty: true

Everytime I run docker-compose up I receive this error message:

test_server | controllers/users.go:4:3: cannot find package "_/go/src/test_server/vendor/github.com/gin-gonic/gin" in any of: test_server |
/usr/local/go/src/_/go/src/test_server/vendor/github.com/gin-gonic/gin (from $GOROOT) test_server |
/go/src/_/go/src/test_server/vendor/github.com/gin-gonic/gin (from $GOPATH)

It's referring to the controllers package. I'm using github.com/kardianos/govendor to vendor my packages. Do you know what's going on?

  • 写回答

3条回答 默认 最新

  • duangu6431 2017-05-26 21:55
    关注

    You need to tell go where find the packages:

    api:
      ...
      environment:
        - GOPATH=/go/src/test_server
    

    Or have a Dockerfile with the proper packages installed (recommended)

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog