postgresql client only
4.5K
Lightweight PostgreSQL client Docker images for versions 12 to 17, based on Alpine Linux. These images provide essential PostgreSQL tools like:
psql (PostgreSQL interactive shell)pg_dump (Backup utility)pg_restore (Restore utility)pg_isready (Check server availability)ā
Lightweight: Uses Alpine Linux to keep the image small (~5-10MB).
ā
No Bloat: Installs only the PostgreSQL client tools (no server).
ā
Multiple Versions: Available for PostgreSQL 12, 13, 14, 15, 16, 17.
ā
Easy to Use: Run psql commands without installing PostgreSQL locally.
ā
Cross-Platform: Works on any system with Docker.
Replace <VERSION> with 12, 13, 14, 15, 16, or 17:
docker pull dattm24/postgresql-client:<VERSION>
Example:
docker pull dattm24/postgresql-client:17
psql ShellConnect to a PostgreSQL database:
docker run --rm -it dattm24/postgresql-client:<VERSION> \
psql -h <DB_HOST> -p <DB_PORT> -U <USERNAME> -d <DATABASE>
Example:
docker run --rm -it dattm24/postgresql-client:17 \
psql -h 192.168.10.12 -p 5435 -U db_master -d learning_postgres
You'll be prompted for the password. To pass it automatically, use
-e PGPASSWORD=<PASSWORD>.
You can execute queries without opening the interactive shell:
docker run --rm -it dattm24/postgresql-client:<VERSION> \
psql -h <DB_HOST> -p <DB_PORT> -U <USERNAME> -d <DATABASE> -c "SELECT version();"
Example:
docker run --rm -it dattm24/postgresql-client:17 \
psql -h 192.168.10.12 -p 5435 -U db_master -d learning_postgres -c "SELECT * FROM countries LIMIT 10;"
pg_dump)docker run --rm dattm24/postgresql-client:<VERSION> \
pg_dump -h <DB_HOST> -p <DB_PORT> -U <USERNAME> -d <DATABASE> > backup.sql
Example:
docker run --rm dattm24/postgresql-client:17 \
pg_dump -h 192.168.10.12 -p 5435 -U db_master -d learning_postgres > backup.sql
pg_restore)cat backup.sql | docker run --rm -i dattm24/postgresql-client:<VERSION> \
psql -h <DB_HOST> -p <DB_PORT> -U <USERNAME> -d <DATABASE>
Example:
cat backup.sql | docker run --rm -i dattm24/postgresql-client:17 \
psql -h 192.168.10.12 -p 5435 -U db_master -d learning_postgres
pg_isready)You can check if a PostgreSQL server is reachable:
docker run --rm dattm24/postgresql-client:<VERSION> \
pg_isready -h <DB_HOST> -p <DB_PORT> -U <USERNAME>
Example:
docker run --rm dattm24/postgresql-client:17 \
pg_isready -h 192.168.10.12 -p 5435 -U db_master
| PostgreSQL Version | Docker Tag |
|---|---|
| 17 | postgresql-client:17 |
| 16 | postgresql-client:16 |
| 15 | postgresql-client:15 |
| 14 | postgresql-client:14 |
| 13 | postgresql-client:13 |
| 12 | postgresql-client:12 |
If you want to build and push images for multiple versions:
for version in 12 13 14 15 16 17; do
docker build --build-arg PG_MAJOR=$version -t dattm24/postgresql-client:$version .
docker push dattm24/postgresql-client:$version
done
This repository is open-source and follows the MIT License.
Content type
Image
Digest
sha256:8c012987dā¦
Size
5.4 MB
Last updated
over 1 year ago
docker pull dattm24/postgresql-client:17