node.js - 无法替换到目录/var/lib/docker/overlay2/if2ip5ok

在我的 Windows 机器上,我正在尝试使用以下 Dockerfile 构建一个容器化的 node.js 应用程序:

  # use latest version of nodejs
  FROM node:lts-alpine
  
  # install aurelia-cli to build the app & http-server to serve static contents
  RUN npm i -g http-server
  RUN npm i -g aurelia-cli
  
  # set working directory to app
  # henceforth all commands will run inside this folder
  WORKDIR /app
  
  # copy package.json related files first and install all required dependencies
  COPY package*.json ./
  RUN npm install
  
  # copy the rest of the files and folders & install dependencies
  COPY . ./
  RUN npm run build
  
  # by default http-server will serve contents on port 8080
  # so we expose this port to host machine
  EXPOSE 8080
  
  CMD [ "http-server" , "dist" ]

但是,docker build 。 Copy 行失败。 ./。消息 cannot replace to directory/var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping with file

我需要做什么来构建我的容器镜像?

最佳答案

node_modules 添加到与 Dockerfile 相同目录中的 .dockerignore 文件中,如 here 所述: (h/t David Maze ).

不太优雅,只需删除项目的 node_modules 目录,然后重新运行 docker build

关于node.js - 无法替换到目录/var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping with file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72955265/

相关文章:

javascript - 我怎样才能从传递给 `String.prototype.replace`

javascript - 尝试在 Mobile Safari 上调试 Javascript 但当 i

regex - 如何从文件中提取一行中存在的所有 IP 地址?

c - 可变参数在多次转发时如何在堆栈上表示?

r - 在行内的顺序中调整很少的频率来计算频率

api - 概念 api 缺少属性值

rust - 使用 std::fs::write 将 Vec 写入文件

html - 在响应图像上放置和缩放文本

perl - 如何为每个 XML 输出添加换行符?

r - 从向量中提取多个子串模式