Docker 使用 Given 作为 STDIN 作为输入构建失败

Docker Build Failing with Given as STDIN as input

为什么 Docker 使用 - 构建图像时构建失败?

主机详细信息

 - docker desktop community 2.1.0.5 for Windows 
 - Windows 10

Docker文件:

FROM ubuntu:latest
MAINTAINER "rizwan@gm.com"

RUN apt-get update \
  && apt-get install -y python3-pip python3-dev \
  && cd /usr/local/bin \
  && ln -s /usr/bin/python3 python \
  && pip3 install --upgrade pip

WORKDIR /app
COPY . /app
COPY requirements.txt /app/requirements.txt
RUN pip3 --no-cache-dir install -r requirements.txt
EXPOSE 5000
CMD ["python3", "my_service.py","--input-path= /input.csv", "--output-path=/output.csv"]

文件夹结构

-Root 
 -Application.py 
 -Dockerfile 
 -requirements.txt

命令

 - Failing :  docker build - < Dockerfile

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

 - Successful: docker build .

当你运行

docker build - < Dockerfile

它只 Dockerfile 发送给 Docker 守护程序,但不发送其他文件。当您告诉 Docker 将 COPY 文件放入图像时,您实际上并没有将文件发送给它。这与在 .dockerignore 文件中包含源代码树中的所有内容非常相似。

通常您会发送 Docker 当前目录作为上下文目录:

docker build .  # knows to look for Dockerfile by default