Unable to COPY config file in nginix /etc/nginx/conf.d/default.conf Unable to COPY config file in nginix /etc/nginx/conf.d/default.conf docker docker

Unable to COPY config file in nginix /etc/nginx/conf.d/default.conf


If the source file path is /app/nginix.conf then dockefile should contain:

COPY /app/nginx.conf /etc/nginx/conf.d/default.conf

If you're running docker build command from /app directory on your host then your above dockerfile should work.

Update:

If you're expecting /app/nginx.conf file of node docker image to present in nginx:alpine image then you need to use multi-stage docker builds.

Change your dockerfile to

FROM node as buildWORKDIR /appCOPY package json files RUN npm buildFROM nginx:alpine COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf

This will copy /app/nginx.conf file from node image to nginx:alpine image.


If somebody is still struggling with this....

changing the WORKDIR from app to builddir worked!

FROM node:alpine as builder WORKDIR '/builddir'COPY package.json .RUN npm installCOPY . .RUN npm run buildFROM nginx:alpineCOPY --from=builder /builddir/build /usr/share/nginx/htmlRUN rm /etc/nginx/conf.d/default.confCOPY nginx/nginx.conf /etc/nginx/conf.dEXPOSE 80CMD ["nginx", "-g", "daemon off;"]