Search code examples
dockerdockerfiledocker-multi-stage-build

COPY command not working as expected in multistage Dockerfile


Stage 1:

FROM node:10.23.0-alpine as react
WORKDIR /app
RUN npm run build

Stage2:

FROM python:3.6-alpine3.7 AS release  
# Create app directory
WORKDIR /app
# In the below line only the contents of the build folder is been copied and not the folder itself
COPY --from=react /app/build ./

From the above Dockerfile I am trying to copy the build folder from stage 1 to python image in stage 2. Only the contents of the build folder is been copied and not the complete folder


Solution

  • create a folder where you want to copy it

    COPY --from=react /app/build ./new_directory