Docker:复制失败:在生成上下文中找不到文件或文件被.dockerignore排除

lfapxunr  于 2022-12-03  发布在  Docker
关注(0)|答案(1)|浏览(472)

我有一个Docker合成文件,它用GitHub URL为上下文设置了一个服务。服务的Dockerfile复制了一个requirements.txt并安装了它。这可以正常工作(COPY requirements.txt /rasa_traind/)。但是当我把该行改为COPY . <dir>时,我得到了一个COPY failed: file not found in build context错误。
Docker撰写

chatbot_server:
    build:
      context: <GitHub URL>
      dockerfile: Dockerfile
    ports:
      - "5005:5005"
    depends_on:
      - rasa_actions_server
      - redis
    extra_hosts:
      - "host.docker.internal:host-gateway" # for docker.host.internal to work on Linux

码头组合建筑

Step 4/8 : RUN pip install --upgrade pip
 ---> Using cache
 ---> 5a584d36ea77
Step 5/8 : COPY . /rasa_traind/
ERROR: Service 'chatbot_server' failed to build: COPY failed: file not found in build context or excluded by .dockerignore: stat rasa_traind/: file does not exist

停靠文件

FROM python:3.8.12-slim-buster

RUN apt-get update

RUN yes | apt-get install python3-dev build-essential

RUN pip install --upgrade pip

# COPY requirements.txt /rasa_traind/ # Works
COPY . /rasa_traind/

RUN pip install -r requirements.txt

WORKDIR /rasa_traind/rasa_actions_server/

CMD ["rasa", "run"]
fhity93d

fhity93d1#

您是否尝试过在COPY . /Rasa_traind/之前设置WORKDIR。类似于以下内容

FROM python:3.8.12-slim-buster

RUN apt-get update

RUN yes | apt-get install python3-dev build-essential

RUN pip install --upgrade pip

WORKDIR /rasa_traind/rasa_actions_server/

# COPY requirements.txt /rasa_traind/ # Works
COPY . /rasa_traind/

RUN pip install -r requirements.txt

CMD ["rasa", "run"]

相关问题