If Docker is not already installed, you can install it using the following commands:
- For Ubuntu/Debian:
sudo apt update
sudo apt install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
- For CentOS/RHEL:
sudo yum install -y docker
sudo systemctl start docker
sudo systemctl enable docker
Verify Docker Installation:
- Check the docker is installed correctly:
docker --version
Download the official PostgreSQL 14 Docker image from Docker Hub:
docker pull postgres:14
This will pull the latest PostgreSQL 14 image.
use sample docker-compose.yml file in root subnet directory.
- Running docker
docker-compose up -d
- Verify the setup
docker ps
- Stop the docker
docker-compose down
- Connect to PostgreSQL
psql -h localhost -U <user_name> -d <db_name> -p <port>