Table of contents
No headings in the article.
As software engineers the amount of tooling out there can become overwhelming. A project might require you to run a number of tools and processes just to enable you to work on the project.
I do not know about you but I get easily fazed by the amount of navigating from one app to another.
I guess someone somewhere was also facing this challenge and came up with the Postman vscode extension that just makes it easy for you to test your API endpoints right in vscode.
Recently I was working on a backend project using PostgreSQL as the database and I just did not feel like starting up pgAdmin. I already had my vscode running, docker desktop, and two different windows of brave browser.
I just needed something that did not add to the complexity of moving from one app to another. So I did what every software engineer would do.
Yeah, I went to Google in search of an answer and you bet I got one that just makes sense.
Remember I said I was already running docker. That is legit the easiest way to get a Postgres database up and running.
The solution I found was running pgadmin as a service in my already running docker container.
It is so easy I was amazed. Here is what I did. I added pgadmin as a service in my docker-compose file.
version: "3.8"
services:
database:
container_name: database
image: postgres:12.8
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD="your database password"
- POSTGRES_DB="your database name"
ports:
- 5432:5432 # specify port where your postgres database will run
volumes:
- db:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
container_name: pg-admin
environment:
PGADMIN_DEFAULT_EMAIL: "Your email"
PGADMIN_DEFAULT_PASSWORD: "your password"
ports:
- "5050:80" # specify port where pgadmin will run
volumes:
db:
What this tells docker is to run a service along side the Postgres database and that service is called pgadmin.
Next, I ran that container using one of my favorite docker commands. This will get the container running and also pull the image of the pgadmin service.
docker-compose up -d
From here I could now access pg admin on my browser when I visit http://localhost:5050 without the need to start up another app.
Here is the screen I was greeted with
Remember I specified a default email and password when creating the pgadmin service. Those are the credentials I will need to log into pgadmin on the web.
There I was smiling from ear to ear one less app to deal with everything in my browser. Next time you are working on a project would you try this ???