{"id":21238715,"url":"https://github.com/shahradelahi/docker-pgbouncer","last_synced_at":"2025-10-02T14:31:04.185Z","repository":{"id":279459964,"uuid":"725603691","full_name":"shahradelahi/docker-pgbouncer","owner":"shahradelahi","description":"A Tiny PgBouncer Docker image based on Alpine Linux.","archived":true,"fork":false,"pushed_at":"2025-04-08T14:34:52.000Z","size":48,"stargazers_count":35,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-12T04:44:41.081Z","etag":null,"topics":["docker","pgbouncer","postgres"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/litehex/pgbouncer/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shahradelahi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-30T13:49:19.000Z","updated_at":"2025-08-05T10:44:39.000Z","dependencies_parsed_at":"2025-02-25T17:52:37.207Z","dependency_job_id":null,"html_url":"https://github.com/shahradelahi/docker-pgbouncer","commit_stats":null,"previous_names":["shahradelahi/docker-pgbouncer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shahradelahi/docker-pgbouncer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fdocker-pgbouncer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fdocker-pgbouncer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fdocker-pgbouncer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fdocker-pgbouncer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shahradelahi","download_url":"https://codeload.github.com/shahradelahi/docker-pgbouncer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Fdocker-pgbouncer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278018075,"owners_count":25915999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-02T02:00:08.890Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","pgbouncer","postgres"],"created_at":"2024-11-21T00:37:54.107Z","updated_at":"2025-10-02T14:31:04.179Z","avatar_url":"https://github.com/shahradelahi.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!WARNING]\n\u003e Not this project is no longer maintained. Use [edoburu/docker-pgbouncer](https://github.com/edoburu/docker-pgbouncer) instead.\n\n# PgBouncer Docker image\n\nA very minimal PgBouncer Docker image based on Alpine Linux.\n\n### Features\n\n- Tiny image size (about 10 MB)\n- Fully configurable via environment variables\n- Support for multiple databases\n- Support for standalone user administration database\n- Support for custom configuration file\n\n### Quickstart\n\n```bash\ndocker run --rm \\\n    -e DATABASE_URL=\"postgres://\u003cuser\u003e:\u003cpassword\u003e@\u003chostname\u003e:\u003cport\u003e/\u003cdatabase_name\u003e\" \\\n    -e USER_\u003cuser\u003e=\"\u003cpassword\u003e\" \\\n    -p 6432:6432 \\\n    litehex/pgbouncer\n```\n\nOr add credentials separately:\n\n```bash\ndocker run --rm \\\n  -e DB_NAME=\"\u003cdatabase-name\u003e\" \\\n  -e DB_USER=\"\u003cpassword\u003e\" \\\n  -e DB_PASSWORD=\"\u003cuser\u003e\" \\\n  -e DB_HOST=\"\u003chost\u003e\" \\\n  -p 6432:6432 \\\n  litehex/pgbouncer\n```\n\nThen you should be able to connect to PgBouncer:\n\n```bash\npsql \"postgresql://\u003cuser\u003e:\u003cpassword\u003e@127.0.0.1:6432/\u003cdatabase-name\u003e\"\n```\n\n### Environment variables\n\nTo configure, please refer to official [PgBouncer documentation](https://www.pgbouncer.org/config.html) and use them as\nenvironment variables with the following format:\n\n```text\n  # -e \u003cPGBOUNCER_OPTION\u003e=\u003cvalue\u003e\n```\n\n##### Example:\n\n```bash\ndocker run --rm \\\n  -e MAX_CLIENT_CONN=100 \\\n  -e DEFAULT_POOL_SIZE=20 \\\n  -p 6432:6432 \\\n  litehex/pgbouncer\n```\n\n### Examples\n\n#### Use a custom configuration\n\nPlease note that by going this way, you cannot use any option from environment variables. This method is only useful if\nyou just want to run PgBouncer on Docker.\n\n```bash\ndocker run --rm \\\n  -v /path/to/pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini \\\n  -p 6432:6432 \\\n  litehex/pgbouncer\n```\n\n#### Create a PgBouncer user\n\nTo define a user and add them to the users section of the auth file, you need to use the following environment\npattern:\n\n```text\nUSER_\u003cname\u003e = \u003cpassword\u003e\n```\n\n##### Example:\n\n```bash\ndocker run --rm \\\n  -e USER_UNICORN=securepassword \\\n  -p 6432:6432 \\\n  litehex/pgbouncer\n```\n\n#### Assign a user to a database\n\nThis method is useful when you want to create a user and assign it to multiple databases.\n\n```bash\ndocker run --rm \\\n  -e DB_\u003cname\u003e=\"host=\u003chostname\u003e port=\u003cport\u003e dbname=\u003cdatabase_name\u003e auth_user=\u003cuser\u003e\" \\\n  -e USER_\u003cname\u003e=\"\u003cpassword\u003e\" \\\n  -p 6432:6432 \\\n  litehex/pgbouncer\n```\n\n#### Create multiple databases with isolated users access\n\n```bash\ndocker run --rm \\\n  -e DB_FIRST=\"host=\u003chostname\u003e port=\u003cport\u003e dbname=\u003cdatabase_name\u003e auth_user=fu\" \\\n  -e USER_FU=\"\u003cpassword\u003e\" \\\n  -e DB_SECOND=\"host=\u003chostname\u003e port=\u003cport\u003e dbname=\u003cdatabase_name\u003e password=\u003cpassword\u003e auth_user=su\" \\\n  -e USER_SU=\"\u003cpassword\u003e\" \\\n  -p 6432:6432 \\\n  litehex/pgbouncer\n```\n\n#### Use docker-compose and the ability to use multiple databases\n\nTo define multiple databases, you have to provide environment variables with the following format:\n\n```text\nDB_URL_\u003cname\u003e = \u003cconnection_string\u003e\n```\n\nOr you can use the following format(Its same as PgBouncer config):\n\n```text\nDB_\u003cname\u003e = host=\u003chostname\u003e port=\u003cport\u003e //...\n```\n\n```yaml\nversion: '3'\nservices:\n  storage-bouncer:\n    container_name: 'storage-bouncer'\n    image: 'litehex/pgbouncer:latest'\n    restart: unless-stopped\n    ports:\n      - '6432:6432'\n    environment:\n      - DB_URL_READ=postgres://\u003cuser\u003e:\u003cpassword\u003e@\u003chostname\u003e:\u003cport\u003e/\u003cdatabase_name\u003e\n      - DB_URL_WRITE=postgres://\u003cuser\u003e:\u003cpassword\u003e@\u003chostname\u003e:\u003cport\u003e/\u003cdatabase_name\u003e\n      - DB_THIRD=\"host=\u003chostname\u003e port=\u003cport\u003e dbname=\u003cdatabase_name\u003e\n```\n\n#### Create an admin user and connect to PgBouncer\n\nFor defining an admin you have to use `ADMIN_USERS` and `ADMIN_PASSWORD` environment variables, it will create a user\nwith given credentials and adds it to config file.\n\n##### 1. Create credentials\n\n```bash\nexport ADMIN_USER=superuser\nexport ADMIN_PASSWORD=$(openssl rand -base64 32)\n```\n\n##### 2. Add credentials to docker command\n\n```bash\ndocker run --rm \\\n  -e ADMIN_USER=$ADMIN_USER \\\n  -e ADMIN_PASSWORD=$ADMIN_PASSWORD \\\n  -p 6432:6432 \\\n  litehex/pgbouncer\n```\n\n##### 3. Connect to PgBouncer administration database\n\n```bash\necho $ADMIN_PASSWORD | psql -h localhost -p 6432 -U $ADMIN_USER pgbouncer\n# Or\npsql \"postgresql://$ADMIN_USER:$ADMIN_PASSWORD@localhost:6432/pgbouncer\"\n```\n\n### Credits\n\nThis project was inspired by [`edoburu/docker-pgbouncer`](https://github.com/edoburu/docker-pgbouncer) and thanks\nto [`edoburu`](https://github.com/edoburu) for their great work.\n\n### License\n\nThis project is licensed under the GPL-3.0 License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Fdocker-pgbouncer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahradelahi%2Fdocker-pgbouncer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Fdocker-pgbouncer/lists"}