📢 Found an issue or want to request a new tool? Open an issue on GitHub
Command line client for PostgreSQL.
# Interactive mode
docker run -it --rm \
-e PGPASSWORD=my_password \
ghcr.io/pabpereza/toolkitbox/postgres:latest \
psql -h my-server.com -U postgres -d my_database
# Run single query
docker run --rm \
-e PGPASSWORD=my_password \
ghcr.io/pabpereza/toolkitbox/postgres:latest \
psql -h my-server.com -U postgres -d my_database -c "SELECT version();"
apiVersion: v1
kind: Pod
metadata:
name: postgres-client
spec:
containers:
- name: postgres-client
image: ghcr.io/pabpereza/toolkitbox/postgres:latest
command: ["sleep", "infinity"]
env:
- name: PGHOST
value: "postgres-service"
- name: PGUSER
value: "postgres"
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: postgres-credentials
key: password
- name: PGDATABASE
value: "mydb"
PostgreSQL Client includes psql, the interactive terminal tool for PostgreSQL, along with additional utilities like pg_dump, pg_restore, and pg_isready. It allows you to execute SQL queries, manage databases, and perform backups.
This component installs postgresql-client from the Alpine Linux repositories.
psql -h hostname -U user -d database
psql "postgresql://user:password@hostname:5432/database"
psql -h hostname -U user -d database -c "SELECT * FROM table"
psql -h hostname -U user -d database -f script.sql
pg_dump -h hostname -U user database > backup.sql
pg_dump -h hostname -U user -Fc database > backup.dump
pg_restore -h hostname -U user -d database backup.dump
pg_isready -h hostname -p 5432
-- List databases
\l
-- Connect to another database
\c database_name
-- List tables
\dt
-- Describe table
\d table_name
-- List users
\du
-- Show command help
\?
-- Execute system command
\! ls -la
-- Quit
\q
| Option | Description |
|---|---|
-h, --host | Server to connect to |
-p, --port | Port (default: 5432) |
-U, --username | Connection user |
-d, --dbname | Database to select |
-c, --command | Execute SQL command and exit |
-f, --file | Execute commands from file |
-W, --password | Force password prompt |
| Variable | Description |
|---|---|
PGHOST | Server host |
PGPORT | Server port |
PGUSER | Connection user |
PGPASSWORD | Password (not recommended in production) |
PGDATABASE | Default database |
v9.6 - PostgreSQL 9.6v10 - PostgreSQL 10v11 - PostgreSQL 11Content type
Image
Digest
sha256:6455cb32b…
Size
8.7 MB
Last updated
23 days ago
docker pull toolkitbox/postgres