How to run multiple postgres docker instances on local machine

When working on multiple projects, I run separate postgres instance for each of them.

Since these are docker instances, this is not a problem as long as they are not running at the same time

If I’m actively working working on multiple projects parallelly, then there are two problems :

  1. Resources : My laptop becomes slow. There is no solution for this 1
  2. Assuming you have LOTs of memory, second problem still remains. Both instances try to bind to local port 5432 the default port. Which does not work. So you need to bind other postgres instances to different local ports like 5433, 5434 and so on. This is controlled via -p in the docker command.

The format is :

Continue Reading »