Docker PostgreSQL DataBase


.env

DATABASE_HOST=localhost
DATABASE_NAME=db
DATABASE_PORT=5432
DATABASE_USER=user
DATABASE_PASSWORD=pass123


$ vi docker-compose.yml


version: '3'
services:
  postgres:
    image: postgres:13-alpine
    restart: always
    container_name: postgres
    hostname: postgres
    ports:
      - ${DATABASE_PORT}:${DATABASE_PORT}
    environment:
      POSTGRES_DB: ${DATABASE_NAME}
      POSTGRES_USER: ${DATABASE_USER}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      DATABASE_PORT: ${DATABASE_PORT}
    volumes:
      - ./PGDATA:/var/lib/postgresql/data


$ docker-compose up


Example:
https://github.com/webmakaka/Uber-Eats-Clone


Run pgadmin in docker container:

$ docker run -e PGADMIN_DEFAULT_EMAIL='[email protected]' -e PGADMIN_DEFAULT_PASSWORD='password1234' -p 5555:80 --name pgadmin dpage/pgadmin4


http://localhost:5555/

login: [email protected]
pass: password1234