无法替换到目录/var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/me



在我的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.dockerignore文件在同一个目录作为Dockerfile,概述:大卫(h/t迷宫)。

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

创建文件.dockerignore并添加node_modules/并尝试重新构建,应该可以解决您面临的错误。

最新更新