Dockerfile syntax

The building blocks of a Dockerfile are a dozen or more directives; most of them are a counterpart of the functions of docker run/create flags. Here we list 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 must be in a Dockerfile, which means that you can have a Dockerfile that contains only one line. Like all 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 out the outcome. The main discrepancy between the two ...

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