gpt4 book ai didi

linux - 如何运行 dockerfile?

转载 作者:太空宇宙 更新时间:2023-11-04 10:02:08 28 4
gpt4 key购买 nike

找到一个要创建镜像的dockerfile并运行: https://gist.github.com/matsuu/d5b4e83b3d591441f01b7be2ede774e2

在我的电脑上将它作为 centos-redhat-8-beta.dockerfile 存储在一个新文件夹中并尝试:

docker build -t centos-redhat-8-beta .

unable to prepare context: unable to evaluate symlinks in Dockerfile path:
lstat /Users/dnk306/docker/centos-redhat-8-beta/Dockerfile: no such file or directory

需要运行的确切命令是什么?

最佳答案

Dockerfile 不是一个扩展,默认情况下,该文件应该被称为 Dockerfile 以便构建命令使用它。

但是,如果您想使用不同的名称,the option -f or flag --file可以帮助您实现这一目标。

docker build -t centos-redhat-8-beta -f centos-redhat-8-beta.dockerfile .

来自文档:

By default the docker build command will look for a Dockerfile at the root of the build context. The -f, --file, option lets you specify the path to an alternative file to use instead. This is useful in cases where the same set of files are used for multiple builds. The path must be to a file within the build context. If a relative path is specified then it is interpreted as relative to the root of the context.

来源:https://docs.docker.com/engine/reference/commandline/build/#text-files

关于linux - 如何运行 dockerfile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55364352/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com