Git 克隆不复制到 WORKDIR [Dockerfile]

Git clone not coping in to WORKDIR [ Dockerfile ]

在构建 docker 图像时 - 运行 git clone rep@rep.com 正在工作。但是我无法将确切的 app.py 移动到 git 存储库中的 WORKDIR(Dockerfile)。

你可以看到我的 git repo 并且可以用我的 Dockerfile 检查它。如有错误请指正

Need Like: it have to clone only app.py from git repo to continer-WORKDIR.

这是我的 Dockerfile

FROM python:3

RUN apt-get update && apt-get install -y \
    unzip \
    git \
    curl


RUN git clone https://github.com/testgithub-trial/docktest.git
WORKDIR /usr/src/app
ADD /docktest /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt


COPY . .


CMD [ "python", "app.py" ]

这是我的文件夹结构。 (注意: requirement.txt 将在本地出现(不在 git 存储库中)

这是我的输出终端。

Sending build context to Docker daemon  4.096kB
Step 1/9 : FROM python:3
 ---> e2e732b7951f
Step 2/9 : RUN apt-get update && apt-get install -y     build-essential     libpng-dev     libjpeg62-turbo-dev     libfreetype6-dev     locales     zip     jpegoptim optipng pngquant gifsicle     vim     unzip     git     curl
 ---> Using cache
 ---> 93a0e5877ac6
Step 3/9 : RUN git clone https://github.com/testgithub-trial/docktest.git
 ---> Using cache
 ---> 36313099edf8
Step 4/9 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 35c1e7a26f44
Step 5/9 : ADD /docktest /usr/src/app
ADD failed: file not found in build context or excluded by .dockerignore: stat docktest: file does not exist

你会想要 RUN mv /docktest /usr/src/appADD 用于构建上下文(您的机器)中的文件,而不是图像本身中的文件