docker - 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 映像。只复制构建文件夹的内容,而不是完整的文件夹
解决方案
创建一个要复制的文件夹
COPY --from=react /app/build ./new_directory
推荐阅读
- batch-file - 批处理 - 如何将(不带扩展名的文件名 + 一些文本 + 带扩展名的文件名)添加到文本文件?
- python - 在字符串列表中查找唯一字符串
- javascript - 仅当它位于字符串末尾时才匹配整个句子
- javascript - 使用 JavaScript 检查是否在范围内输入数字
- reactjs - 在 React 中的 Canvas 元素上加载图像
- r - 需要使用 readRDS 从我的桌面导入 RDS 文件。确切的代码是什么?
- xamarin - 实时更新地理位置
- c# - 在 .NET Core 3.0 中使用登录
- mysql - 为什么 MariaDB 10.4.8(最新版)不能更改此列类型?
- sql - 为什么在 plpgsql 函数的循环中执行比在没有函数的情况下为每个循环独立执行要慢得多?