5

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](https://github.com/docker-library/...) 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](https://github.com/docker-library/...)

Comments
  • 1
    I am not 100% sure what you mean to achieve but if you just need a postgresql server you will definitely wanna go with the 2) approach. That's exactly the point that the postgresql server image has already been built for you, put in a registry (docker.io) so that you can pull it with one line in your Dockerfile.
  • 0
    Remember that containers are only abstractions between os and application. So they have no state if you don’t define them explicitly. For database most important is defined volume.
Add Comment