Postgres connection with docker

Hii, My name is Harshita Chaudhary, I am a data engineer. I have joined Hashnode to share my day to day learnings with you guys, I like to write tech blogs on the fundamental topics of data engineering in a concise manner adding proper and practical examples.
Happy learning and Keep Querying !!
Steps to create a docker container of postgres image:-
Start PowerShell.
Download the Postgres docker image.
Start the docker container in detached mode with the name postgres-0 specify port -p as 5432 and POSTGRES_PASSWORD as the password.
Check the status of running containers
Go inside
container_namein interactive mode.
docker pull postgres #download image
docker run --name postgres-0 -e POSTGRES_PASSWORD=password -d -p 5432:5432 postgres
docker ps ##show running container
docker exec -it postgres-0 bash
ls
psql --help
\du ##role name i.e. super user
create database test;
\l ##list of databases
Create sample data.
CREATE DATABASE test;
\c test
CREATE TABLE test_table(something int);
INSERT INTO test_table VALUES (123);
SELECT * FROM test_table;
\q



