首页 > 解决方案 > COPY 命令在多级 Dockerfile 中未按预期工作

问题描述

阶段1:

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

第二阶段:

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 ./

从上面的 Dockerfile 我试图将构建文件夹从阶段 1 复制到阶段 2 的 python 映像。只复制构建文件夹的内容,而不是完整的文件夹

标签: dockerdockerfiledocker-multi-stage-build

解决方案


创建一个要复制的文件夹

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


推荐阅读