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 26 / 45

What Is a Dockerfile?

This lesson is for anyone tired of repeating the same steps to build an image. A Dockerfile is a text file describing how to build an image: which base to start from, what to install, what to run.

You write instructions such as FROM, COPY, RUN and CMD in order. Running docker build against the file then produces the image automatically, following exactly those steps.

You could build an image by typing commands into a container by hand, but writing them in a Dockerfile means anyone can reproduce the same image, any number of times.

A common stumble is not realizing that the order of instructions is the order the image's layers stack up in — an inefficient order makes for slow, bloated builds.

In real work, the Dockerfile lives in the repository alongside the source code, so every developer builds the image identically.

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)