Public | Automated Build

Last pushed: 4 days ago
Short Description
Developer Image(s) - Andahme Postgres
Full Description

Quick Start (Host Networking)

Start Server

NOTE: Creates initial user (postgres) with password (2345).
NOTE: Creates an initial user database (postgres).

docker run -d --name postgres \
  --network host \
  andahme/postgres

Run Client

NOTE: The 'host' network is necessary when connecting to the localhost interface.

docker run -it --rm \
  --network host \
  andahme/postgres psql -h localhost

Quick Start (User Defined Network)

Create Network

docker network create ${NETWORK:=andahme}

Start Server

NOTE: Publishes the database on (5432) of the localhost interface (127.0.0.1).

docker run -d --name postgres \
  --network ${NETWORK} \
  --publish 127.0.0.1:5432:5432 \
  andahme/postgres

Run Client

NOTE: The default host connection (PGHOST) has been pre-defined (postgres).

docker run -it --rm \
  --network ${NETWORK} \
  andahme/postgres psql

Explicit Initialization/Startup

Initialize Database

NOTE: Initializes a data volume (pg-data) with a new database cluster.
NOTE: Removes the application container (-rm) after initialization.

docker run -it --rm \
  --volume pg-data:/var/lib/postgresql \
  andahme/postgres init

Start Server

NOTE: Mount the data volume (pg-data) to an application container.
NOTE: Connects to a user defined network (${NETWORK}) with alias (postgres).

docker run -d --name postgres \
  --network ${NETWORK} \
  --volume pg-data:/var/lib/postgresql \
  andahme/postgres noinit

Other Tips

Run in Single-User Mode

NOTE: Do not attempt to use on a running database.

docker run -it --rm \
  --volumes-from postgres \
  andahme/postgres postgres --single
Docker Pull Command
Owner
andahme
Source Repository