π₯οΈ Using psql
psql
is the command-line tool for interacting with your PostgreSQL database.
SuperStack makes it easy to run psql inside the container using a helper
script.
π Open a psql Shell
To connect interactively:
bin/postgres
Example output:
psql (17.5 (Debian 17.5-1.pgdg120+1))
Type "help" for help.
app=#
ποΈ By default,
bin/postgres
opens apsql
shell. You can also run other commands in the container likebin/postgres bash
if needed, or psql explicitly withbin/postgres psql
.
πΉ Run Inline SQL Commands
You can also run SQL directly without opening an interactive shell:
bin/postgres -c 'select * from movie;'
β
Because bin/postgres
defaults to psql
, you donβt need to type psql
explicitly.
βοΈ Customize psql Behavior
You can persist your preferences using .psqlrc
and .inputrc
.
π§ Step 1: Create a config directory
mkdir -p postgres/rc
π .psqlrc
Create postgres/rc/.psqlrc
with your preferred settings:
\pset pager off
\setenv PAGER 'less -S'
See the official psql reference for all available options.
π .inputrc
Create postgres/rc/.inputrc
to set readline behavior:
set editing-mode vi
π Step 2: Mount and apply the configs
Add to your compose.override.yaml
(this file is for development-only
overriding of compose.yaml
):
services:
postgres:
volumes:
- ./postgres/rc:/rc:ro
environment:
PSQLRC: /rc/.psqlrc
INPUTRC: /rc/.inputrc
π Step 3: Restart the Postgres container
docker compose up -d --force-recreate postgres