Member-only story
How to Run PostgreSQL and pgAdmin Using Docker
PostgreSQL administration is made easier with Docker
You can use pgAdmin as an alternate solution if you don’t like managing your database using the command-line interface. It’s a web-based front-end for the PostgreSQL database server.
We will be using Docker for our setup since we don’t want to worry about environment management. By using Docker, we don’t have to worry about the installation of PostgreSQL or pgAdmin. Moreover, you can use Docker to run this project on macOS, Windows, and Linux distributions.
From this post, you’ll learn how to connect pgAdmin to a PostgreSQL database server using Docker.
Setup
First, you will need to install Docker. I’ll use macOS for demonstration purposes.
Method 1
We will use a Docker compose file for our first method, and we need to put the docker-compose.yml inside a folder. In this case, the name of the folder is pgAdmin. Let’s break down the individual ingredients of the docker-compose.yml file.
version: '3.8'
services:
db:
container_name: pg_container
image: postgres
restart: always
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: test_db
ports…