Dockerfile: COPY failed: file not found in build context or excluded by .dockerignore:

Hello everybody,

I am currently struggling with COPY instruction in Dockerfile.

When put instruction inside the Dockerfile:
COPY test_copy.txt .
and after that start build image I get the result :
COPY failed: file not found in build context or excluded by .dockerignore: stat test_copy.txt: file does not exist

File test_copy.txt is stored in the same dir as Dockerfile.
My guess is that should be copied test_copy.txt file to inside the root of the container, but not working.

To mention that I did not have a .gitignore file.

It is .dockerignore not .gitignore. How do you try to build the image? You must et the build context properly. To test what is in your build context, try to copy a whole context:

COPY . /context

I sometimes create files with incorrect names like test_copy. txt.
Notice the extra space before the extension. You can to delete the file and create again but I assume it was not the first file you tried.