R
R
reqww2021-02-05 22:22:56
PostgreSQL
reqww, 2021-02-05 22:22:56

PgBouncer and Postgresql in Docker?

Trying to connect Pgbouncer and Postgresql inside docker.

docker-compose:

version: '3'

services:
db:
    container_name: web_postgresql
    image: postgres:13.0
    volumes: 
      - pg_data:/var/lib/postgresql13/data/
    ports:
      - 5432:5432
    environment: 
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_db=postgres

  pgbouncer:
    container_name: pgbouncer
    build: ./pgbouncer
    restart: always
    env_file:
      - pgbouncer/pgbouncer.env
    ports:
      - 6432:6432
    depends_on:
      - db


Pgbouncer.ini
[databases]
*= host=db port=5432

[pgbouncer]
pool_mode = transaction
listen_addr = *
listen_port = 6432
auth_type = md5
auth_file = /opt/pgbouncer/etc/userlist.txt
max_client_conn = 5000
default_pool_size = 20
min_pool_size = 10
reserve_pool_size = 10
max_db_connections = 50
max_user_connections = 50
ignore_startup_parameters = extra_float_digits

# Log settings
log_connections = 0
log_disconnections = 0
admin_users = postgres

pgbouncer.env
DATABASES_HOST=db
DATABASES_PORT=5432
DATABASES_USER=postgres
= Postgres
DATABASES_PASSWORD DATABASES_DBNAME = postgres

PGBOUNCER_LISTEN_ADDE * =
PGBOUNCER_LISTEN_PORT = 6432

PGBOUNCER_MAX_CLIENT_CONN = 5000
PGBOUNCER_DEFAULT_POOL_SIZE = 20

PGBOUNCER_MIN_POOL_SIZE = 10
PGBOUNCER_RESERVE_POOL_SIZE = 10
PGBOUNCER_MAX_DB_CONNECTIONS = 50
PGBOUNCER_MAX_USER_CONNECTIONS = 50
PGBOUNCER_LOG_CONNECTIONS = 0
PGBOUNCER_LOG_DISCONNECTIONS = 0
PGBOUNCER_ADMIN_USERS = postgres
PGBOUNCER_AUTH_TYPE md5 = userlist.txt

"
postgres" "postgres Dockerfile

for Pgbouncer
FROM pgbouncer/pgbouncer

COPY pgbouncer.ini /opt/pgbouncer/etc/pgbouncer.ini
COPY userlist.txt /opt/pgbouncer/etc/userlist.txt


601d9aade9325568671112.png

I lift containers. I can easily connect to postgres via psql with a password and username postgres.
And I can’t access pgbouncer in any way.

No matter what I try, I don't understand where the error is.

I will be grateful for help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question