我正在学习Docker和Kubernetes,刚刚开始我的第一个项目。当我尝试构建我的第一个容器时,我收到以下错误



我已经为一个微服务应用程序建立了一个结构。auth是我所做的第一个Dockerfile,据我所知,它没有构建。

C:UsersgeeksDesktopNorthernHerpGeckoSalesNorthernHerpGeckoSalesauth>docker build -t giantgecko/auth .
[+] Building 0.1s (9/9) FINISHED
=> [internal] load build definition from Dockerfile                                                                                                                                                                                    0.0s
=> => transferring dockerfile: 206B                                                                                                                                                                                                    0.0s
=> [internal] load .dockerignore                                                                                                                                                                                                       0.0s
=> => transferring context: 53B                                                                                                                                                                                                        0.0s
=> [internal] load metadata for docker.io/library/node:alpine                                                                                                                                                                          0.0s
=> [1/5] FROM docker.io/library/node:alpine                                                                                                                                                                                            0.0s
=> [internal] load build context                                                                                                                                                                                                       0.0s
=> => transferring context: 479B                                                                                                                                                                                                       0.0s
=> [2/5] WORKDIR /app                                                                                                                                                                                                                  0.0s
=> CACHED [3/5] COPY package.json .                                                                                                                                                                                                    0.0s
=> CACHED [4/5] RUN npm install                                                                                                                                                                                                        0.0s
=> ERROR [5/5] COPY /Users/geeks/Desktop/NorthernHerpGeckoSales/NorthernHerpGeckoSales/auth .                                                                                                                                          0.0s
------
> [5/5] COPY /Users/geeks/Desktop/NorthernHerpGeckoSales/NorthernHerpGeckoSales/auth .:
------
failed to compute cache key: "/Users/geeks/Desktop/NorthernHerpGeckoSales/NorthernHerpGeckoSales/auth" not found: not found

我可以通过更改我的Dockerfile来解决这个问题:

FROM node:alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "start"]

修复是在我将COPY从绝对路径更改为. .之后,并使用npm cache clean -f清除npm缓存。

你能分享更多关于你的Dockerfile的细节吗?但根据你的错误,它似乎停在复制阶段。您需要提供<source><destination>。下面是一个基于错误的示例:

WORKDIR /app
COPY /Users/geeks/Desktop/NorthernHerpGeckoSales/NorthernHerpGeckoSales/auth /app/auth

默认情况下,所有文件将被复制到WORKDIR

下你可以在这里查看Dockerfile的官方文档https://docs.docker.com/engine/reference/builder/#copy

相关内容

  • 没有找到相关文章