我是docker的新手,在使用具有多种要求的Django时,我遇到了构建新图像的问题。它没有能够安装它们。
我正在
Could not open requirements file: [Errno 2] No such file or directory: 'requirements/local.txt'
Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements/local.txt' returned a non-zero code: 1`
我的代码是:
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements/local.txt /code/
RUN pip install -r requirements/local.txt
COPY . /code/
在运行docker-compose up
?
欢呼声
答案 0 :(得分:3)
在你的Dockerfile
中:
COPY requirements/local.txt /code/
如果你在此之后添加......
RUN ls
......你可以看到:
Step 5 : RUN ls
---> Running in 88fd7cc1a616
local.txt
所以你想要:
RUN pip install -r local.txt
<强>更新强>
没有魔力;如果要维护本地结构,则需要在Dockerfile中明确说明。你可以这样做:
COPY requirements requirements
将整个requirements
目录复制到/code
,或者您可以执行此操作:
RUN mkdir requirements
COPY requirements/local.txt requirements/local.txt