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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.