Wednesday, December 30, 2020

How To Run PostgreSQL on a Docker Container On Ubuntu 20.04

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Docker is an open-source platform where we can create, deploy, and run applications by using containers. Docker is similar to virtual machines (VM), but in VM you need to create a virtual operating system, while Docker allows applications to use the system kernel.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Testing Environment:
Ubuntu 20.04 LTS                     Hostname - www.yourdomain.com  - ip Address - 192.168.1.10  
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
apt update ; apt install -y build-essential net-tools curl git software-properties-common neofetch apt-transport-https ca-certificates curl gnupg-agent docker.io docker-compose

systemctl enable --now docker ; docker --version ; docker-compose version
usermod -aG docker $USER ; newgrp docker
 
docker pull postgres
Or
docker pull postgres:11.5
docker run --name my_postgres -e POSTGRES_PASSWORD=password -d postgres:11.5
docker ps
docker exec -it my_postgres bash
/usr/bin/psql -U postgres postgres
\q

docker logs my_postgres
docker stop my_postgres
docker start my_postgres
docker rm -f my_postgres

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment