I'd like to instruct Docker to COPY
my certificates from the local /etc/
folder on my Ubuntu machine.
I get the error:
COPY failed: file not found in build context or excluded by .dockerignore: stat etc/.auth_keys/fullchain.pem: file does not exist
I have not excluded in .dockerignore
How can I do it?
Dockerfile:
FROM nginx:1.21.3-alpine
RUN rm /etc/nginx/conf.d/default.conf
RUN mkdir /etc/nginx/ssl
COPY nginx.conf /etc/nginx/conf.d
COPY ./etc/.auth_keys/fullchain.pem /etc/nginx/ssl/
COPY ./etc/.auth_keys/privkey.pem /etc/nginx/ssl/
WORKDIR /usr/src/app
I have also tried without the dot
--> same error
COPY /etc/.auth_keys/fullchain.pem /etc/nginx/ssl/
COPY /etc/.auth_keys/privkey.pem /etc/nginx/ssl/
By placing the folder .auth_keys
next to the Dockerfile --> works, but not desireable
COPY /.auth_keys/fullchain.pem /etc/nginx/ssl/
COPY /.auth_keys/privkey.pem /etc/nginx/ssl/
COPY
files that are located within your local source tree; you'll need tocp
the files outside Docker space. How to include files outside of Docker's build context? discusses this further, though it's impractical to pass the entire host filesystem as the build context. – MortyCOPY
them into an image, though, since they can be very easily copied back out. Thedocker run -v
option or Composevolumes:
can inject arbitrary host content into a container and isn't subject toCOPY
's path restrictions. – MortyCOPY filexyz /src/filexyz
Now, my current working directory on host didn't have any filexyz file so it failed. – Hodgkinson