我正在尝试在我的 Windows 机器上构建一个 docker 映像,但我不断收到此错误:
[+] Building 2.1s (12/15)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 538B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 35B 0.0s
=> [internal] load metadata for docker.io/library/node:alpine 1.0s
=> [ 1/11] FROM docker.io/library/node:alpine@sha256:6b56197d33a56cd45d1d1214292b8851fa1b91b2ccc678cee7e5fd4260bd8fae 0.0s
=> [internal] load build context 1.0s
=> => transferring context: 15.72kB 1.0s
=> CACHED [ 2/11] WORKDIR /app 0.0s
=> CACHED [ 3/11] COPY package.json . 0.0s
=> CACHED [ 4/11] COPY tsconfig.json . 0.0s
=> CACHED [ 5/11] COPY swagger.yaml . 0.0s
=> CACHED [ 6/11] COPY services . 0.0s
=> CACHED [ 7/11] RUN yarn install 0.0s
=> ERROR [ 8/11] ADD . /app 0.0s
------
> [ 8/11] ADD . /app:
------
cannot copy to non-directory: /var/lib/docker/overlay2/xw77p2bxfkhhnwqs5umpl7cbi/merged/app/.git
我的 Dockerfile 如下:
FROM node:alpine
#Create Directory for the Container
WORKDIR /app
#Copy the package.json and tsconfig.json to work directory
COPY package.json .
COPY tsconfig.json .
COPY swagger.yaml .
COPY services .
#Install all packages
RUN yarn install
#Copy all other source code to work directory
ADD . /app
#Build sources
RUN yarn run build
#Clean src directory
RUN rm -rf ./src/
RUN rm -rf ./services/src/
#Expose Ports
EXPOSE 3000
#Entry
CMD ["yarn", "start"]
这个 Dockerfile 在我同事的 Linux 机器上工作,但在我的 Windows 机器上失败。
这是我的 Docker 版本
Docker version 20.10.7, build f0df350
在 Windows 上运行并使用 wsl 2 与之交互。
但是使用 Windows 命令提示符构建也会失败。
预先感谢您的帮助!