- All Courses
- Docker Essentials
- Building Images
- Writing a Dockerfile
Lesson 2.1
Writing a Dockerfile
A Dockerfile lists the steps to build an image.
12mBeginner24.5k students
Overview
A build script with caching semantics
A Dockerfile lists the steps to build an image. Each instruction produces a layer, so the order you write them in determines both the size of the result and how much of it can be reused on the next build.
ENTRYPOINT declares what the container is; CMD supplies the default arguments. Getting them the wrong way round is why an image ignores the command you pass it.
Pin the base image to a specific version. A floating latest tag means today build and tomorrow build are not the same thing, and the difference will surface at the worst possible moment.
In this lesson you will:
- Choose an appropriate base image
- Understand each instruction you write
- Tell CMD and ENTRYPOINT apart
Resources
Notes are not saved yet — they clear when you leave this page.
Previous Lesson
Namespaces, cgroups, and the isolation illusion
8m
Layer caching and build speed
14m