15

Visual Studio Code (1.22.2) 提供了.dockerfile在保存对话框中命名的文件扩展名。具有此扩展名的文件是什么?到目前为止,我所看到的所有文档和示例中都有一个 Dockerfile,仅称为Dockerfile.

在此处输入图像描述

如果我Dockerfile作为文件名输入,Dockerfile.dockerfile则会创建一个名为的文件。

4

6 回答 6

10

Dockerfile

ADockerfile是一个文本文档,其中包含用户可以在命令行上调用以组装image. 使用docker build用户可以创建一个连续执行多个命令行指令的自动构建。Docker images是容器的基础。AnImage是根文件系统更改和在容器运行时中使用的相应执行参数的有序集合。图像通常包含堆叠在一起的分层文件系统的联合。图像没有状态,它永远不会改变更多关于

Dockerfile 扩展

ADockerfile没有扩展名。如果您在 Windows 上的 docker 上使用notepad ++docker 在保存时创建 dockerfile,请选择“All type”并将文件名保存为“Dockerfile”。

MongoDB/Dockerfile

在此处输入图像描述

关于 Docker

Docker是推动容器运动的公司,也是唯一一家解决混合云中所有应用程序的容器平台提供商。当今的企业面临着数字化转型的压力,但受到现有应用程序和基础设施的限制,同时还要合理化日益多样化的云、数据中心和应用程序架构组合。Docker实现应用程序和基础架构以及开发人员和 IT 运营之间的真正独立,以释放他们的潜力,并创建一个更好的协作和创新模型更多关于

于 2018-06-14T23:47:28.117 回答
7

看来“*.dockerfile”只是传统“Dockerfile”名称的替代品。如果您想将一组 dockerfile 保存在同一目录中,这可能很有用。注意 中的-f/--file选项docker help build

-f, --file string Dockerfile 的名称(默认为 'PATH/Dockerfile')

换句话说,您不需要使用名称“Dockerfile”,VSCode 扩展将正确地语法高亮任何以“.dockerfile”结尾的文件。

于 2021-04-18T14:23:31.647 回答
2

使用 .dockerfile 扩展名告诉 VSCode 该文件是用于代码突出显示和 linting 的 DockerFile

于 2021-02-11T01:13:49.743 回答
1

对我有用的是将 VS Code 中的文件保存为 Dockerfile。但是,在运行 $docker-compose up 命令之前,您需要删除 VS Code 放置的 .dockerfile 扩展名:

在此处输入图像描述

于 2019-07-18T20:00:11.207 回答
-1

Even though VSCode can deal with extensionless files just fine, some major parts of the Windows operating system can't. Try double clicking a Dockerfile (without extension) in the Windows Explorer. You will always be asked which program you want to open it in because Windows can't map extensionless files to a default program.

My guess is that because of this problem, Microsoft would like for all files to have an extension and uses VSCode to nudge people towards using a file extension for Dockerfiles, ignoring the fact that this contradicts the de facto standard.

于 2021-07-28T13:56:10.083 回答
-3

Dockerfile 没有任何扩展。
从 hte 文档https://docs.docker.com/compose/gettingstarted/可以看出,它没有任何扩展。

Dockerfile

于 2019-10-07T18:20:02.837 回答