我试图为我的盖茨比应用程序构建Docker映像。每当我运行命令docker构建。-t gatsbyapp,它会给出一个错误:

failed to solve with frontend dockerfile.v0: failed to build LLB:
failed to compute cache key: "/.env" not found: not found

同时我的Dockerfile如下所示:

FROM node:13

WORKDIR /app

COPY package.json .

RUN yarn global add gatsby-cli

RUN yarn install

COPY gatsby-config.js .

COPY .env .

EXPOSE 8000

CMD ["gatsby","develop","-H","0.0.0.0"]

当前回答

我也有同样的问题,我所要做的就是将Docker配置文件名大写:

Dockerfile >没有工作

Dockerfile >工作

其他回答

对于docker桌面,这个问题通常通过添加-f选项来解决。 例如:让docker文件放在c:\Dockerfile.txt

您可以运行以下命令来构建映像

docker build -f "c:\Dockerfile.txt"

如果你在Mac或Windows上使用Docker Desktop,你可能也必须在你的“Docker引擎”JSON配置中禁用它。

Docker Desktop→Settings→Docker Engine→将“features”:{buildkit: true}改为“features”:{buildkit: false}。

通过设置HTTP_PROYY和HTTP_PROXYS环境变量来指定代理服务器。

例子:

http_proxy=http://username:password@proxy.example.com:8080
https_proxy=http://username:password@proxy.example.com:8080

对我来说

我打开Docker桌面->打开设置->Docker引擎->

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": false
  }
}

这里我的buildkit的默认值是true ->我更改为false并重新启动docker引擎

这对我很有用

如果你在Windows上使用Docker,那么确保Docker引擎被设置为与你想要构建的映像(Windows / Linux)匹配的模式。