Frictionless Local Postgres with Docker Compose

Frictionless Local Postgres with Docker Compose

PostgreSQL is a very powerful open source database that is available everywhere from a developer laptop to cloud providers. I have been using PostgreSQL for decades starting in 1998. I am always looking for ways to optimize my dev workstation configuration.

PgAdmin 4 is the graphical interface for working with Postgres. It is is a single page web application written in JavaScript that talks to a backend written in python. Using docker-compose it is possible to run both pgAdmin and postgres inside docker, as shown in the diagram below.

final configuration: apps, containers, virtual machines on a developer workstation

Because pgAdmin runs as a server it asks for a username/password to access the UI. After logging in to pgAdmin you have to setup a connection to the database that you want administer. The login and connection setup are annoying when developing locally.

Setting up pgAdmin with pre-configured connectivity and passwords is tricky. It requires in depth understanding of docker, docker-compose, shell scripting, and how pgAdmin works. I put together an example implementation at https://github.com/asaikali/docker-compose-postgres with all the gory technical details explained in the repository’s readme.md file.