🐘 Setup PostgreSQL — Relational Database

Deploy a powerful, open-source PostgreSQL database on Ubuntu with Docker. The script auto-generates secure credentials and displays connection details at the end.

⚠️ This script is provided for demo and testing purposes only. Not intended for production use.

📦 Resources & Setup Scripts

Grab the automated bash script from GitHub to follow along with the video.

Automated install script — auto-generates secure DB credentials.
View on GitHub

Quick Install:

wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/postgres/postgres-ubuntu.sh
chmod +x postgres-ubuntu.sh
sudo bash postgres-ubuntu.sh

Tutorial Steps

1 Download & Run the Script

The script installs Docker, generates a secure random password, and starts PostgreSQL with a ready-to-use database and user.

wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/postgres/postgres-ubuntu.sh
chmod +x postgres-ubuntu.sh
sudo bash postgres-ubuntu.sh

2 Save Your Connection Details

The script displays the generated credentials at the end. Save them immediately:

FieldValue
Userpgadmin
Databasepgdb
Passwordauto-generated — shown at end of script
Port5432

3 Connect with psql

psql -h <server-ip> -U pgadmin -d pgdb

4 Run a Test Query

-- Check connection
SELECT version();

-- Create a test table
CREATE TABLE test (id SERIAL PRIMARY KEY, name TEXT);
INSERT INTO test (name) VALUES ('Hello, PostgreSQL!');
SELECT * FROM test;

Ports Used

PortPurpose
5432PostgreSQL