sudhar chrome
sudhar chrome

Reputation: 75

Git clone not coping in to WORKDIR [ Dockerfile ]

while building a docker image - RUN git clone [email protected] is working. But i can't able to move the exact app.py in to WORKDIR (Dockerfile), which is in the git repo.

you can see my git repo & can chek it with my Dockerfile. please correct me if I am wrong

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

Here is My 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" ]

Here is my Folder structure. (Note: requirement.txt will be locally present (not in git repo)

Here is my Folder structure

Here is my Output Terminal.

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

Upvotes: 0

Views: 1452

Answers (1)

C.Nivs
C.Nivs

Reputation: 13106

You'll want to RUN mv /docktest /usr/src/app. ADD is for files in the build context (your machine), not ones in the image itself

Upvotes: 2

Related Questions