snippets
This post is part of a learning series: Quick Snippets

Create postgres database in docker

Posted by Vikash on Saturday, Apr 1, 2023 Reading time: 1 Min

Create the postgresql container

1
2
3
4
5
6
docker run -d --name postgres \
 -e POSTGRES_PASSWORD=RunningFlying2 \
 -e PGDATA=/var/lib/postgresql/data/pgdata \
 -v postgres_data:/var/lib/postgresql/data \
 -p 5432:5432
 postgres:latest

E´╗┐xplaination:

The above command will create a container with latest version of Postgres.

Here are the container and postgres database details.

  • Container Name: postgres
  • Docker Volume: postgres_data
  • Host: 127.0.0.1
  • Port: 5432
  • User: postgres
  • Password: RunningFlying2

That’s all for now.