gpt4 book ai didi

docker - Dockerfile中是否需要 `FROM`子句?

转载 作者:行者123 更新时间:2023-12-02 06:26:48 26 4
gpt4 key购买 nike

对于我遇到过的所有Dockerfile(虽然数量不多),它们都使用FROM子句作为现有镜像的基础,即使它是FROM scratch

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

编辑
我读

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



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

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

最佳答案

根据官方文档,它是必需的:

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

关于docker - Dockerfile中是否需要 `FROM`子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58330046/

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