Ad space (banner)
AD

Got the fundamentals? A structured Docker course is a fast way to level up.

Find Docker courses on Udemy

Affiliate link. Costs you nothing extra.

🐳Docker Lessons
Lesson 27 / 45

Choosing a Base Image with FROM

This lesson answers "what do I write at the very top of a Dockerfile?" The FROM instruction names the base image your image is built on — the mandatory first instruction.

The syntax is FROM base-image[:tag]. You start from an existing official image (say node or python) and add your application on top.

Writing FROM node:18 uses the official image with Node.js 18 already installed as the foundation, and every later instruction stacks on top of it.

A common stumble is assuming FROM is optional. It is required, and it must come first.

In real work, choosing a lightweight base (an alpine variant, for instance) is a standard way to keep the final image small.

Docker
Try it (type this into the pseudo terminal)
docker build -t myapp .

🧑‍💻 You can type this command into the Docker pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)