Member-only story

How to Run PostgreSQL and pgAdmin Using Docker

PostgreSQL administration is made easier with Docker

Mahbub Zaman
Towards Data Science
5 min readJan 25, 2021

--

Photo by bongkarn thanyakij from Pexels and Guillaume Bolduc on Unsplash

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…

--

--

Towards Data Science
Towards Data Science

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Mahbub Zaman
Mahbub Zaman

Written by Mahbub Zaman

I create open-source developer productivity tools, intending to streamline and enhance workflow: binarytree.dev

Responses (12)