[英]cannot replace to directory /var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping with file
On my Windows machine, I am attempting to build a containerized node.js application with the following Dockerfile:在我的 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" ]
However, docker build .
但是, docker build .
fails at the line Copy . ./
在Copy . ./
Copy . ./
. Copy . ./
. with the message cannot replace to directory /var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping with file
.消息cannot replace to directory /var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping with file
。
What do I need to do to get my container image to build?我需要做什么来构建我的容器映像?
Add node_modules
to a .dockerignore
file in the same directory as your Dockerfile, as outlined here : (h/t David Maze ).将node_modules
添加到与 Dockerfile 位于同一目录中的.dockerignore
文件中,如下所述:(h/t David Maze )。
Less gracefully, simply delete the project's node_modules
directory then rerun docker build
.不太优雅,只需删除项目的node_modules
目录,然后重新运行 docker docker build
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.