Wednesday, February 16, 2022

Deploy Run PostgreSQL 14 On Docker / Docker Compose | Rocky Linux


 in This Tutorial you will Learn " How To Deploy PostgreSQL On Docker Container Or Docker Compose On Rocky Linux"
PostgreSQL is an advanced, enterprise-class, and open-source relational database system.
Docker is an open-source virtualization technology known a containerization platform for software containers.
Rocky Linux is an open-source enterprise operating system designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux.
_________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      |    IP -192.168.1.20        |     Hostname - www.primaryhost.com
_________________________________________________________________________________________
cat /etc/system-release ; sestatus ; dnf groupinstall "Development Tools" -y
docker --version ; docker-compose --version
docker run -d \
        --name my-postgres \
        -p 5432:5432 \
        -v ~/apps/postgres:/var/lib/postgresql/data \
        -e POSTGRES_PASSWORD=andpasswd \
        -e POSTGRES_USER=and_user \
        -e POSTGRES_DB=and_db \
         postgres:14-alpine
docker ps
docker exec -it my-postgres /bin/bash
psql -U and_user -d and_db;
select version();
\q
docker stop my-postgres  | docker rm my-postgres
_________________________________________________________________________________________
Deploy PostgreSQL - Docker Compose

nano docker-compose.yaml
version: '3.9'

services:
  postgres:
    image: postgres:14-alpine
    ports:
      - 5432:5432
    volumes:
      - ~/apps/postgres:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=T3cret
      - POSTGRES_USER=and_user
      - POSTGRES_DB=and_db

docker-compose up -d
docker-compose ps
docker-compose exec postgres /bin/bash
psql -U and_user -d and_db;
select version();
_________________________________________________________________________________________



No comments:

Post a Comment