Building Docker images best practices

I have been experimenting with Docker and reading articles on it. I was wondering what are best practices for building Docker images. Many articles have recommended that use Alpine base images because they’re small and more secure.

Let us say that my application needed Postgre. What is the best approach?

  1. Use the Alpine Dockerfile provided here at Github. Download the file and go to where its located in my terminal and enter “docker build”

  2. Creating a Dockerfile from scratch and using the command “FROM postgre:10-alpine”

  3. Use the Alpine template file provided here