Sign inSign up

dattm24/postgresql-client

By dattm24

•Updated over 1 year ago

postgresql client only

Image
Developer tools
1

4.5K

dattm24/postgresql-client repository overview

⁠PostgreSQL Client Docker Image

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)

ā šŸ“Œ Why Use This Image?

āœ… 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.


ā šŸš€ How to Use

⁠1ļøāƒ£ Pull a Specific Version

Replace <VERSION> with 12, 13, 14, 15, 16, or 17:

docker pull dattm24/postgresql-client:<VERSION>

Example:

docker pull dattm24/postgresql-client:17

⁠2ļøāƒ£ Run Interactive psql Shell

Connect 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>.


⁠3ļøāƒ£ Run a Query in One Command

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;"

ā šŸ”„ Database Backup & Restore

⁠Backup a Database (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
⁠Restore a Database (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

ā šŸ” Check Database Connection (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

ā šŸ“Œ Available Versions

PostgreSQL VersionDocker Tag
17postgresql-client:17
16postgresql-client:16
15postgresql-client:15
14postgresql-client:14
13postgresql-client:13
12postgresql-client:12

ā šŸ› ļø Build & Push (For Contributors)

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

ā šŸ“„ License

This repository is open-source and follows the MIT License.


ā šŸš€ Now You Can Use PostgreSQL Clients Without Installing PostgreSQL Server!

Tag summary

Content type

Image

Digest

sha256:8c012987d…

Size

5.4 MB

Last updated

over 1 year ago

docker pull dattm24/postgresql-client:17