Dockerfile
What Dockerfile is and common commands
Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.
Instructions
Order of instructions in Dockerfile matters, as all commands on Dockerfile as executed sequentially, and some instruction resulting in its own layer, increasing image size as a result. Instructions that are changing more frequently should be placed closer to the bottom, and instructions that don't change or change less frequently, should be placed higher in the Dockerfile. When one of the instruction changes, COPY
for instance, all subsequent instructions must be re-run.
For more best practices see: Dockerfile best practices
Sample Dockerfile
Building image
Last updated