Reputation: 19863
I have a folder called public
which is gitignored.
I have this Dockerfile
FROM nginx
ADD public /usr/share/nginx/public/
# COPY public /usr/share/nginx/public/
COPY nginx.conf /etc/nginx/conf.d/default.conf
Now when I create image, I get this error
Step 2/3 : COPY public /usr/share/nginx/public/
COPY failed: file not found in build context or excluded by .dockerignore: stat public: file does not exist
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
I figured out if I exclude public
folder from gitignore then all is good.
I checked there is no .dockerignore
file.
Just make sure if it's fallback issue, I created a new .dockerignore
file with empty content
Upvotes: 0
Views: 644
Reputation: 19863
Finally figure it out, I was using gcloud build
command to create docker file, and seems google by default ignores gitignore files.
https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore
so I created a .gcloudignore
file with below content
*
!public
Upvotes: 1