Skip to content

Instantly share code, notes, and snippets.

@johnoscott
Forked from jdaarevalo/docker-compose.yaml
Last active April 14, 2022 01:19
Show Gist options
  • Save johnoscott/4885a575399cc160c9c1b44455479791 to your computer and use it in GitHub Desktop.
Save johnoscott/4885a575399cc160c9c1b44455479791 to your computer and use it in GitHub Desktop.
docker_compose_postgres
# https://hub.docker.com/_/postgres
# Usage:
# $ docker compose up
# NOTE: version not required as of compose spec v
# version: '3.7'
# docker run --name basic-postgres --rm \
# -e POSTGRES_USER=postgres \
# -e POSTGRES_PASSWORD=postgres \
# -e PGDATA=/var/lib/postgresql/data/pgdata \
# -v /tmp:/var/lib/postgresql/data \
# -p 5432:5432 \
# -it postgres:14.1-alpine
services:
postgres:
image: postgres:latest
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=warehouse # default is POSTGRES_USER
ports:
- '5438:5432'
# log all requests (ie. all)
# command: ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]
command: ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]
volumes:
- ./postgres-data:/var/lib/postgresql/data
# copy the sql script to create tables
- ./sql/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment