How do you specify the base image in a Dockerfile?

Prepare for the Docker Foundations Test. Review essential Docker concepts with multiple choice questions, each with hints and explanations. Ace your exam!

In a Dockerfile, the base image is specified using the FROM instruction. This instruction serves as the foundation for the Docker image you are building. It allows you to define which existing image your new image will be based upon. The image specified can be a fully qualified image from a container registry like Docker Hub or a locally available image.

Using the FROM instruction is essential because it sets the starting point of your image and defines the environment where subsequent commands in the Dockerfile will be executed. This can include specifying the operating system or any pre-installed software that the image might need to run applications.

Other instructions such as ENV, RUN, and CMD have different purposes. ENV is used to set environment variables, RUN executes commands during the image build process, and CMD defines the default command to run when a container is created from the image. These instructions do not play a role in defining the base image, which is why using the FROM instruction is crucial for building Docker images correctly.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy