问题描述
我正在尝试使用here
中描述的方法Dockerfile
FROM python:3.8
copY requirements.txt setup.py /tmp/
RUN pip3 install -r /tmp/requirements.txt \
&& rm /tmp/*
此操作失败,并显示以下信息:
Step 1/7 : FROM python:3.8
---> 79cc46abd78d
Step 2/7 : copY requirements.txt setup.py /tmp/
---> Using cache
---> a50a0a8ecb06
Step 3/7 : RUN pip3 install -r /tmp/requirements.txt && rm /tmp/*
---> Running in c7d29bd8f23c
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml'
found.
我还尝试注释掉RUN
命令,进入容器并运行
手动pip3 install -r /tmp/requirements.txt
。这项工作没有错误。
我不知道这里可能是什么问题。
解决方法
我知道了:
点.
与requirements.txt
无关,而是与当前工作目录有关。手动执行此操作的原因是,我还将我的工作空间安装到了一个devcontainer中,并将我的工作目录包含在该工作空间中,其中也包含setup.py
因此,解决方案是执行以下操作:
WORKDIR /tmp
COPY requirements.txt setup.py ./
RUN pip3 install -r requirements.txt \
&& rm /tmp/*