How to run PostgreSQL in Docker
Feb 3, 2021
Step — 1: Pull Image
docker pull postgres
Step — 2: Create Container
docker run --name postgres -e POSTGRES_PASSWORD=MySuperStrongP@ssw0rdLol -p 5432:5432 -d postgres
Parameter Description
--name postgres
define container name aspostgres
-e POSTGRES_PASSWORD
define default password for userpostgres
-p 5432:5432
map container port 5432 with local port 5432
-d
run container in detach mode
Step — 3: Connect it
host: localhost
port: 5432
username: postgres
password: <password from step 2>
Connect to PostgreSQL container with your favorite Database client like PgAdmin, DBeaver