Skip to content

Latest commit

 

History

History
68 lines (48 loc) · 2.62 KB

pg-dockerfile.md

File metadata and controls

68 lines (48 loc) · 2.62 KB

Setting Up PostgreSQL 14.2 with Dockerfile

This document provides instructions for setting up a PostgreSQL 14.2 database using a Dockerfile.

Contents [↑]

init-pg-user-db.sql [↑]

Dockerfile [↑]

  • Create a Dockerfile file, and add the following content.

    FROM postgres:14.2
    
    # Copy the SQL script to create a user and a database
    COPY ./init-pg-user-db.sql /docker-entrypoint-initdb.d/

Build the Docker image [↑]

  • Build the Docker image using the following command.

    host$ docker image build -f Dockerfile -t pg-14.2 .

Start the PostgreSQL container [↑]

Connect to the PostgreSQL service [↑]

Stop container [↑]

Reference [↑]

  • Reference:
    • Docker Hub - Postgres
      • start a postgres instance
      • POSTGRES_PASSWORD
      • PGDATA
      • Docker Secrets
      • Initialization scripts