【问题标题】:I Can't build my docker file to create my docker image using Docker build我无法使用 Docker build 构建我的 docker 文件来创建我的 docker 映像
【发布时间】:2021-06-09 23:16:08
【问题描述】:

当我尝试构建我的 docker 文件时,docker 返回以下错误:

[+] Building 0.0s (1/2)                                                                                                                                                                                                                                       
 => ERROR [internal] load build definition from Dockerfile                                                                                                                                                                                               0.0s
 => => transferring dockerfile: 36B                                                                                                                                                                                                                      0.0s
------
 > [internal] load build definition from Dockerfile:
------
failed to solve with frontend dockerfile.v0: failed to read dockerfile: error from sender: walk Dockerfile: not a directory

有人知道如何解决这个问题吗?
提前谢谢你

【问题讨论】:

  • 您能否在问题中包含完整的docker build 命令?
  • 同时编辑Dockerfile的问题和内容

标签: docker dockerfile docker-image docker-build


【解决方案1】:

很难 100% 确定如何使用所提供的信息来指导您,但看起来您可能直接提供了文件路径而不是文件夹路径(您可以阅读更多 in the doc):

# this is used to build a Dockerfile file inside directory /PATH/TO/FOLDER
docker build /PATH/TO/FOLDER

如果你想给出 Dockerfile 路径而不是文件夹路径,你可能需要这样做(再次阅读the doc for more):

# this is used to build a Dockerfile file given its content
docker build - < /PATH/TO/FOLDER/Dockerfile

(请注意,这里有更多微妙之处,因为在第一种情况下,您使用上下文构建而不是在第二种情况下,我让您阅读 Docker 的文档,它相当不错)。

【讨论】:

    【解决方案2】:

    这种类型的错误一般是因为Dockerfile的名字不对。检查名称是否完全是“Dockerfile”,只有大写字母 D,并且没有扩展文件。

    【讨论】:

    • 没用,错误还在
    • 你能显示Dockerfile的内容吗?
    【解决方案3】:

    docker version 20.10.5, Mac: Big Sur 11.2.3(最新)出现同样的错误

    即使是基本图像...

    FROM nginx
    CMD [ "sleep", "30000" ]
    

    存在证书问题,但 brew updatebrew upgrade --force 为我工作。我希望这会有所帮助:-)

    【讨论】:

      猜你喜欢
      • 2019-07-05
      • 1970-01-01
      • 1970-01-01
      • 2021-12-24
      • 2016-08-27
      • 2020-05-21
      • 2016-05-18
      • 1970-01-01
      • 2021-12-01
      相关资源
      最近更新 更多