FROM
)MAINTAINER
, LABEL
)apt-get install
, apk add
)bower.json
, package.json
, build.gradle
, requirements.txt
)npm install
, pip install
)CMD
, ENTRYPOINT
, ENV
, EXPOSE
)These orderings are made for optimizing build time using Docker's built-in caching mechanism.
Rule of thumbs:
Parts that change often (e.g. codebase) should be placed near bottom of Dockerfile, and vice-versa. Parts that rarely change (e.g. dependencies) should be placed at top.