Group common operations
Docker builds images as a collection of layers. Each layer can only add data, even if this data says that a file has been deleted. Every instruction creates a new layer. For example:
RUN apt-get -qq update RUN apt-get -qq install some-package
Has a couple of downsides:
apt-get updatealone in a
RUNstatement causes caching issues and subsequently
apt-get installinstructions may fail. Suppose you later modify
apt-get installby adding extra packages, then docker interprets the initial and modified instructions as identical and reuses the cache from previous steps. As a result the
apt-get updatecommand is not executed because its cached version is used during the build.
RUN apt-get -qq update && \ apt-get -qq install some-package
as this only produce one layer.
Mention the maintainer
This is usually the second line of the Dockerfile. It tells who is in charge and will be able to help.
LABEL maintainer John Doe <email@example.com>
If you skip it, it will not break your image. But it will not help your users either.
Keep your Dockerfile short. If a complex setup is necessary, consider using a dedicated script or setting up base images.