douwen4178 2018-05-04 16:54
浏览 156

使用docker build可以很好地构建映像,但是stat / GO / src / main:docker-compose不会遇到此类文件或目录

I have a Dockerfile which I can successfully build an image from:

FROM iron/go:dev
RUN mkdir /app
COPY src/main/main.go /app/.
# Set an env var that matches your github repo name, replace treeder/dockergo here with your repo name
ENV SRC_DIR=/app
# Add the source code:
ADD . $SRC_DIR
# Build it:
RUN go get goji.io
RUN go get gopkg.in/mgo.v2
RUN cd $SRC_DIR; go build -o main
ENTRYPOINT ["/app/main"]

However, when I attempt to build the following docker-compose.yml file:

version: "3.3"

services:
  api:
    build: ./api
    expose:
      - '8080'
    container_name: 'api'
    ports:
      - "8082:8080"
    depends_on:
      - db
    networks:
      - api-net

  db:
    build: ./db
    expose:
      - '27017'
    container_name: 'mongo'
    ports:
      - "27017:27017"
    networks:
      - api-net

networks:
  api-net:
    driver: bridge

I get:

Removing api mongo is up-to-date Recreating

532e3cf66460_carsupermarket_api_1 ... error

ERROR: for 532e3cf66460_carsupermarket_api_1 Cannot start service api: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/GO/src/main\": stat /GO/src/main: no such file or directory": unknown

ERROR: for api Cannot start service api: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/GO/src/main\": stat /GO/src/main: no such file or directory": unknown ERROR: Encountered errors while bringing up the project.

I suspect that docker-compose is introducing some nuance when it comes to directory build paths, however, I'm at a loss as to why my image is building from the docker file when using docker build ., but failing when I try to incorporate this into docker-compose.

Can someone point me in the right direction as to what I am doing wrong?

  • 写回答

1条回答 默认 最新

  • dongzong5017 2018-05-05 02:04
    关注

    I've upgraded to the latest version of Docker CE (18.03.1-ce, build 9ee9f40) and this appears to have resolved the issue.

    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办