首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能用文件替换到目录/var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping

不能用文件替换到目录/var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping
EN

Stack Overflow用户
提问于 2022-07-12 16:05:56
回答 1查看 888关注 0票数 0

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

代码语言:javascript
复制
  # 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

要构建容器映像,我需要做些什么?

EN

回答 1

Stack Overflow用户

发布于 2022-07-12 16:05:56

node_modules添加到与您的Dockerfile相同的目录中的.dockerignore文件,如概述的这里:(h/t 戴维·麦子)。

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72955265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档