Problem in my Dockerfile when I try to COPY

251 Views Asked by At

I have a test_app.sh like this :

#! /bin/bash
mkdir tempdir
mkdir tempdir/templates
mkdir tempdir/static
cp test_app.py tempdir/.
cp -r templates/* tempdir/templates/.
cp -r templates/* tempdir/static/.
#Création du fichier Dockerfile 

#Lancement du build de l'image testapp à partir de Dockerfile sous /tempdir
echo "FROM python" >> tempdir/Dockerfile
echo "RUN pip3 install flask" >> tempdir/Dockerfile
echo "COPY  ./tempdir/static /home/myapp/static/" >> tempdir/Dockerfile
echo "COPY  ./templates /home/myapp/templates/" >> tempdir/Dockerfile
echo "COPY  test_app.py /home/myapp/" >> tempdir/Dockerfile
echo "EXPOSE 8080" >> tempdir/Dockerfile
echo "CMD python3 /home/myapp/test_app.py" >> tempdir/Dockerfile

#Lancement du build de l'image testapp à partir de Dockerfile sous /tempdir
cd tempdir
docker build -t testapp .

#lancement du container  testrunning avec l'image testapp
docker run -t -d -p 8080:8080 --name testrunning testapp

#Tester si le container a bien démarré
docker ps -a

So in the Dockerfile created I have this :

FROM python
RUN pip3 install flask
COPY  ./tempdir/static /home/myapp/static/
COPY  ./templates /home/myapp/templates/
COPY  test_app.py /home/myapp/
EXPOSE 8080
CMD python3 /home/myapp/test_app.py

And the architecture of my project is:

projet_devops_eval
├── tempdir
│   ├── Dockerfile
│   ├── sample_app.py
│   ├── static
│   │   └── index.html
│   ├── templates
│   │   ├── index1.html
│   │   ├── index2.html
│   │   ├── index3.html
│   │   └── index.html
│   └── test_app.py
├── templates
│   └── index.html
├── test_app.py
└── test_app.sh

but when I run the test_app.sh I got this error:

Step 3/7 : COPY  ./tempdir/static /home/myapp/static/
COPY failed: file not found in build context or excluded by .dockerignore: stat tempdir/static: file does not exist
Unable to find image 'testapp:latest' locally
docker: Error response from daemon: pull access denied for testapp, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.

can you explain me and help me to resolve the COPY error please

0

There are 0 best solutions below