Photo by David Ireland / Unsplash

PostgreSQL, pgAdmin on Docker

PostgreSQL Aug 14, 2022

This post briefly documents the process of using Postgres, pgAdmin via Docker container.

Introduction

PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.

pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL

Goals

  1. Pull Docker Images from Docker Hub
  2. Run the downloaded Postgres, pgAdmin Docker Image
  3. Connect to the Database via pgAdmin
  4. Interact with the MySQL Database via pgAdmin
  5. Container Management (Stop, Restart, Stats)
  6. Cleanup (Remove)

Minimum Software Requirements

Getting Started

Setup

Connect to Database via pgAdmin

http://localhost:5050/

login

Email Address : root@admin.com
Password : root

CREATE TABLE accounts (
	user_id serial PRIMARY KEY,
	username VARCHAR ( 50 ) UNIQUE NOT NULL,
	password VARCHAR ( 50 ) NOT NULL,
	email VARCHAR ( 255 ) UNIQUE NOT NULL,
	created_on TIMESTAMP NOT NULL DEFAULT now()
);

INSERT INTO accounts(username,password,email) VALUES('John Doe','mySecret','example@domain.com');

SELECT * FROM accounts;

Connect to DB via Terminal

8

docker exec -it postgres-latest /bin/sh

psql -U admin -d sample_db -W

Password: admin

sample_db=# \l

sample_db=# \dt

sample_db=# SELECT * FROM accounts;

sample_db=# exit

# exit

Cleanup (Remove)

docker-compose down

Tags

Anantha Raju C

| Poetry | Music | Cinema | Books | Visual Art | Software Engineering |