gpt4 book ai didi

docker - 使用 docker build 构建图像很好,但是 stat/GO/src/main : no such file or directory encountered with docker-compose

转载 作者:数据小太阳 更新时间:2023-10-29 03:22:58 26 4
gpt4 key购买 nike

我有一个 Dockerfile,我可以从中成功构建镜像:

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

但是,当我尝试构建以下 docker-compose.yml 文件时:

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

我得到:

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.

我怀疑 docker-compose 在目录构建路径方面引入了一些细微差别,但是,我不知道为什么在使用 docker build 时我的图像是从 docker 文件构建的。,但是当我尝试将其合并到 docker-compose 时失败了。

有人能指出我做错了什么的正确方向吗?

最佳答案

我已经升级到最新版本的 Docker CE(18.03.1-ce,build 9ee9f40),这似乎解决了这个问题。

关于docker - 使用 docker build 构建图像很好,但是 stat/GO/src/main : no such file or directory encountered with docker-compose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50179815/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com