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_name
in 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