Postgres with Docker in 30s

version: '3.8'

services:
  postgres:
    image: postgres:latest
    environment:
      POSTGRES_DB: your_database
      POSTGRES_USER: your_user
      POSTGRES_PASSWORD: your_password
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    ports:
      - "5432:5432"

volumes:
  postgres_data:

Start the container via $ docker compose up. The connection URL will be your_user:your_password@localhost:5432/your_database.