Can't create a docker image for COPY failed: stat /var/lib/docker/tmp/docker-builder error

I want to create a docker image. This is my work directory: Dockerfile.in test.json test.py

And this is my Dockerfile:

COPY ./test.json /home/test.json
COPY ./test.py /home/test.py

RUN python test.py

When i launch this command: docker build -f Dockerfile.in -t 637268723/test:1.0 .

It gives me this error:

`Step 1/5 : COPY ./test.json /home/test.json
 ---> Using cache
 ---> 6774cd225d60
 Step 2/5 : COPY ./test.py /home/test.py
 COPY failed: stat /var/lib/docker/tmp/docker-builder428014112/test.py: 
 no such file or directory`

Can anyone help me?


You should put those files into the same directory with Dockerfile.


Check if there's a .dockerignore file, if so, add:

!mydir/test.json
!mydir/test.py