To learn more, check out Best practices for writing Dockerfiles.
Use Alpine as base image. Small and a full Linux distribution
FROM alpine
Add MAINTAINER to ensure people know who to contact
MAINTAINER John Smith <john.smith@abc.com>
Run multiple commands in one RUN statement, connected by &&
RUN apt-get update && apt-get install -y subversion
Split long RUN statements on multiple lines to keep them readable
RUN apt-get update && apt-get install -y \
bzr \
cvs \
git \
mercurial \
subversion \
&& rm -rf /var/lib/apt/lists/*
Use ENV to set environment variables used by the entrypoint applications
ENV PG_MAJOR=9.3
ENV PG_VERSION=9.3.4
RUN curl -SL https://example.com/postgres-$PG_VERSION.tar.xz | tar -xJC /usr/src/postgres && …
ENV PATH=/usr/local/postgres-$PG_MAJOR/bin:$PATH
Use COPY not ADD to copy files onto the containers
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
COPY . /tmp/
Use USER to run as a non-root user
USER Johnsmith