Skip to content

antwit090/postgres-docker-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL Docker Template

A simple Docker setup for running a PostgreSQL database.

Setup

  1. Update the files in the secrets-example directory with your desired credentials.

  2. Rename the secrets-example directory to secrets.

  3. Create the Docker network:

docker network create postgres-network
  1. Start the PostgreSQL container:
docker compose up -d

If the port is already in use, change the POSTGRES_HOST_PORT variable in the .env file.

  1. To stop the container:
docker compose down

Access

The database is reachable from:

  • localhost:<POSTGRES_HOST_PORT> on the local machine
  • postgres:5432 from other containers in the Docker network postgres-network

Volume

The pgdata volume persists the database, so data is not lost when stopped.

To stop and delete the volume (this will erase ALL database data):

docker compose down -v

Port Configuration

The current port binding restricts access to the local machine.

To allow other machines on the network to connect, change it to:

ports:
  - "${POSTGRES_HOST_PORT}:5432"

⚠️ Note (Linux users): Doing this bypasses UFW rules — see Docker and UFW.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published