Dcoker Start to end

Start the PostgreSQL Container

docker run --name postgres-learn \

  -e POSTGRES_PASSWORD=mysecretpassword \

  -p 5432:5432 \

  -d postgres   


ACCESS the SQL Shell (psql) inside the Container

docker exec -it postgres-learn psql -U postgres

Rul you first query to list all database

\l

Create New Data Base

CREATE DATABASE learning_db;   

Connect to your new database

\c learning_db

Create Table inside the database

CREATE TABLE students (

  id SERIAL PRIMARY KEY,

  name VARCHAR(50),

  age INT

  gender VARCHAR(50)

);

Insert in the database

INSERT INTO students (name, age) VALUES ('Alice', 25);

INSERT INTO students (name, age) VALUES ('Bob', 30);   

Exit the shell

\q

Before Restart the container Check total container

docker ps -a
Container Start
docker start <container-id or container-name>

Comments

Popular posts from this blog

VERTICAL SCALING 💋

CyberSecurity

The Journey of Data — "Frontend → Backend → Database → Frontend"