Defining Our First Custom Image

In real life, a factory doesn’t come out of nowhere. It has to be constructed from blueprints: detailed plans and instructions that describe exactly what it’s supposed to look like. Docker’s container factories—in other words, images—are no different. They require a special blueprint file aptly named a Dockerfile. A Dockerfile uses special syntax to describe exactly how the image should be constructed. If you’ve heard the expression infrastructure as code, this is an example of it: a Dockerfile describes how a machine image is configured as shown in the figure.

images/dockerfiles-images-and-containers.png

A Dockerfile is made up of various instructions

Get Docker for Rails Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.