What is a Dockerfile, and which instructions does a basic one contain?
Short answer
A Dockerfile is the recipe for an image: which base image, what to copy, which commands to run at build time, and which program runs when the container starts. docker build reads it top to bottom, each instruction is a cached step.
3 points to say:
- Only
RUN,COPY,ADDcreate layers; when an instruction changes, it and every one after it rerun. RUNruns at build,CMD/ENTRYPOINTrun at start; preferCOPYoverADD, andENTRYPOINTin exec form..dockerignoreand instruction order (rarely-changing things first) decide build speed.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.