Sobes.tech
Junior — Middle

What role does the FROM instruction play in a Dockerfile if it is the only command in the file?

sobes.tech AI

Answer from AI

The FROM instruction in a Dockerfile specifies the base image from which a new image will be built. If FROM is the only command in the Dockerfile, the resulting image will be exactly the same as the specified base image, with no changes.

This can be used, for example, for:

  • Renaming or re-tagging an existing image.
  • Creating a stub image that simply references the base.

Example Dockerfile:

FROM ubuntu:20.04

The resulting image will be identical to ubuntu:20.04.

Thus, FROM sets the foundation, and without additional commands, Dockerfile does not modify the image.