The syntax of a Dockerfile

The building blocks of a Dockerfile are a dozen directives. Most of these are made up of functions of the docker run/create flags. Let's take a look at the most essential ones:

  • FROM <IMAGE>[:TAG|[@DIGEST]: This is to tell the Docker daemon which image the current Dockerfile is based on. It's also the one and only instruction that has to be in a Dockerfile; you can have a Dockerfile that contains only this line. Like all of the other image-relevant commands, the tag defaults to the latest if unspecified.
  • RUN:
 RUN <commands> RUN ["executable", "params", "more params"]

The RUN instruction runs one line of a command at the current cache layer and commits the outcome. The main discrepancy between the two forms is ...

Get DevOps with Kubernetes - Second Edition 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.