在基于图像的Python中,我想使用go包诺斯替运行一个命令(*): RUN gnostic --grpc-out=test test/openapi/loyalty-bff.yaml我确实写了以下泊坞文件:FROM golang:1.17 AS golangRUN go get -u github.com/google/gnostic@latestRUN go get -u github.com/googleapis/gnostic-grpc@latestFROM python:3.7.10WORKDIR /appADD requirements.txt /app/RUN pip install -r requirements.txtADD . /app/COPY --from=golang /go/bin/gnostic /go/bin/gnostic-grpcCMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"]我在运行命令 (*) 时出错:Command 'gnostic --grpc-out=loyalty-bff-1634180849463365375 loyalty-bff-1634180849463365375/loyalty-bff.yaml' returned non-zero exit status 127.另一方面,我可以在不使用多阶段时运行。替换为在基于映像的 go 中安装 python,但构建时间很长:FROM golang:1.17WORKDIR /appRUN go get -u github.com/google/gnostic@latestRUN go get -u github.com/googleapis/gnostic-grpc@latestRUN apt-get updateRUN apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev wget libbz2-devRUN wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgzRUN tar -xf Python-3.7.8.tgzRUN cd Python-3.7.8 \ && ./configure --enable-shared \ && make && make installRUN apt-get install python3-pip -yADD requirements.txt /app/RUN pip3 install -r requirements.txtADD . /app/CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"]
1 回答
一只斗牛犬
TA贡献1784条经验 获得超2个赞
退出代码通常意味着找不到可执行文件。127
如果你正在寻找 env 的 ,你可以默认看到 有:golang:1.17PATH/go/bin
$ docker run --rm -it golang:1.17 env
PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=a9b7efb588ea
TERM=xterm
GOLANG_VERSION=1.17.2
GOPATH=/go
HOME=/root
这就是为什么你可以在基于戈兰的容器中找到的原因。gnostic
但是,在 中,它是下一个:python:3.7.10
$ docker run --rm -it python:3.7.10 env
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
因此,对于您的方案,将副本更改为 next 可以使其正常工作:
COPY --from=golang /go/bin/gnostic /go/bin/gnostic-grpc /usr/local/bin/
- 1 回答
- 0 关注
- 104 浏览
添加回答
举报
0/150
提交
取消