当我尝试docker image build -t py-test
时得到这个错误错误:Could not install packages due to an OSError: [Errno 2]没有这样的文件或目录:'/tmp/tmp_ohy_f6g/output.json'
execute failed running [/bin/sh -c pip install ibm-db]: exit code: 1
dockerfile:
FROM python:3.9.13-alpine3.16
WORKDIR /app
RUN pip install --upgrade setuptools
RUN pip install --upgrade pip
RUN pip install ibm-db
RUN pip install flask
EXPOSE 8080
COPY . .
CMD ["python", "output.py"]
Docker版本20.10.16,build aa7e414
macOS (localhost) version——macOS montery version 12.4 (21F79)
在详细模式下运行pip
(pip install -v ibm-db
)的构建后,您可以看到以下错误:
No Gcc installation detected.
Please install gcc and continue with the installation of the ibm_db.
ibm-db
要求你在安装它的时候有gcc
可用,这样你就可以构建它的C模块。
在ibm-db
解决问题之前安装gcc
和libc-dev
:
FROM python:3.9.13-alpine3.16
WORKDIR /app
RUN apk add gcc libc-dev
RUN pip install --upgrade setuptools
RUN pip install --upgrade pip
RUN pip install ibm-db
RUN pip install flask
COPY . .
EXPOSE 8080
CMD ["python", "output.py"]