docker hub postgres code example

Example 1: postgres docker compose

version: '3'
services:
  postgres-service:
    image: postgres:latest
    container_name: postgres-container
    ports:
      - 55432:5432/tcp
    environment:
      POSTGRES_DB: pg_db
      POSTGRES_PASSWORD: appdbpassword
    volumes:
      - /var/lib/postgres
      - ./dbscripts/postgres:/docker-entrypoint-initdb.d

Example 2: docker postgres

$ docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres

Example 3: backup postgres database docker

docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql

Tags:

Css Example