Skip to content
/ pgcli Public

pgcli container for postgres with password urlencoding

License

Notifications You must be signed in to change notification settings

devpies/pgcli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pgcli

pgcli container for postgres with password urlencoding

Getting Started

Run a container with the postgres connection string.

docker run --rm -it devpies/pgcli postgres://user:pass@host:port/database

URL Encoding Passwords If Neccessary

devpies/pgcli can handle passwords in both encoded and unencoded forms, reducing the risk of connection errors due to improper encoding.

Approach

  1. The image first tries to connect using the password as provided, assuming it doesn’t need encoding. This avoids unnecessary encoding when it’s not needed.

  2. If the initial connection fails, the image then URL-encodes the password and retries the connection, ensuring that special characters in the password are correctly handled.

Using Docker Compose

Add a service to your project's compose file and place it on the same network as the postgres container. Provide the postgres connection string as an environment variable: CONN.

services:
  pgcli:
    image: devpies/pgcli
    environment:
      CONN: $CONN
    networks:
      - dbaccess

Then run:

docker compose run --rm pgcli

Note: You might notice with docker compose up, pgcli starts alongside your other services but exits immediately. This is normal. Containers exit when they don't have a running process to keep it alive.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

pgcli container for postgres with password urlencoding

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published