Skip to content

Instantly share code, notes, and snippets.

@duyhenryer
Last active December 6, 2020 14:46
Show Gist options
  • Save duyhenryer/89c098e14e67ef25941372395faf03be to your computer and use it in GitHub Desktop.
Save duyhenryer/89c098e14e67ef25941372395faf03be to your computer and use it in GitHub Desktop.

Postgresql & PgAdmin

version: '3.5'

services:
  postgres:
    container_name: postgres_container
    image: postgres
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-postgres}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
      PGDATA: /data/postgres
    volumes:
       - postgres:/data/postgres
    ports:
      - "5432:5432"
    networks:
      - dockernet
    restart: unless-stopped
  
  pgadmin:
    container_name: pgadmin_container
    image: dpage/pgadmin4
    environment:
      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
    volumes:
       - pgadmin:/root/.pgadmin
    ports:
      - "${PGADMIN_PORT:-5050}:80"
    networks:
      - dockernet
    restart: unless-stopped

networks:
  dockernet:
    driver: bridge

volumes:
    postgres:
    pgadmin:

Postgresql & PgAdmin powered by compose

Requirements:

  • docker >= 17.12.0+
  • docker-compose

Quick Start

  • Clone or download this repository
  • Go inside of directory, cd compose-postgres
  • Run this command docker-compose up -d

Environments

This Compose file contains the following environment variables:

  • POSTGRES_USER the default value is postgres
  • POSTGRES_PASSWORD the default value is changeme
  • PGADMIN_PORT the default value is 5050
  • PGADMIN_DEFAULT_EMAIL the default value is pgadmin4@pgadmin.org
  • PGADMIN_DEFAULT_PASSWORD the default value is admin

Access to postgres:

  • localhost:5432
  • Username: postgres (as a default)
  • Password: changeme (as a default)

Access to PgAdmin:

  • URL: http://localhost:5050
  • Username: pgadmin4@pgadmin.org (as a default)
  • Password: admin (as a default)

Add a new server in PgAdmin:

  • Host name/address postgres
  • Port 5432
  • Username as POSTGRES_USER, by default: postgres
  • Password as POSTGRES_PASSWORD, by default changeme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment