Dockerfile是否需要`FROM`子句? [英] Is `FROM` clause required in Dockerfile?

查看:918
本文介绍了Dockerfile是否需要`FROM`子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我遇到过的所有Dockerfile(确实并不多),它们都使用了 FROM 子句来建立现有映像,甚至如果是从头开始

For all the Dockerfiles I've come across thus (which admittedly is not many), all of them have used a FROM clause to base off an existing image, even if it's FROM scratch.

是否需要此条款?是否有可能没有 FROM 子句的Dockerfile?这样创建的容器可以执行任何操作吗?

Is this clause required? Is it possible to have a Dockerfile with no FROM clause? Will this container created thus be able to do anything?

EDIT

我读过

EDIT
I read


没有FROM指令的Dockerfile没有父映像,被称为
a基本映像。

A Dockerfile with no FROM directive has no parent image, and is called a base image.

https://docs.docker.com/glossary/?term=parent% 20image

但是我认为这可能是一个错误。

But I think this may be an error.

推荐答案

根据官方文档要求:


FROM 指令初始化一个新的构建阶段,并为后续指令设置基本
映像。因此,有效的Dockerfile 必须
FROM 指令开头。该图像可以是任何有效图像–从公共
存储库中拉出图像,特别容易启动

The FROM instruction initializes a new build stage and sets the Base Image for subsequent instructions. As such, a valid Dockerfile MUST start with a FROM instruction. The image can be any valid image – it is especially easy to start by pulling an image from the Public Repositories.

https://docs.docker.com/engine/reference/builder /#from

这篇关于Dockerfile是否需要`FROM`子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆