复制 Docker 中包含子目录的文件夹

Copy folder with sub directory in Docker

我正在尝试复制包含内容的文件夹。但是当试图从 docker 访问文件时,它显示错误

ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements/development.txt'

我的 Dockerfile 包含:

FROM python
ENV PYTHONUNBUFFERED=1
RUN apt-get update \
    && pip install pip install gunicorn
WORKDIR /usr/src/app

COPY requirements/* /usr/src/app/
RUN pip install -r requirements/development.txt
COPY . .
EXPOSE 8000
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "3", "cryb.wsgi:application"] 

COPY requirements/* /usr/src/app/

您正在将需求中的内容复制到 /usr/src/app。这不会保留目录结构。做到这一点

RUN mkdir /usr/src/app/requirements
COPY requirements/* /usr/src/app/requirements/