如何在 docker-compose 中配置 pgbouncer 和 postgresql [关闭]

问题描述 投票:0回答:0

如何在我的 docker-compose 文件中使用

pgbouncer
应用连接池。不知道我容器的
ConnectionString
对不对

postgredb:
    image: postgres
    environment:
      - POSTGRES_USER=dbuser
      - POSTGRES_PASSWORD=dbpassword
      - POSTGRES_DB=postgres
    restart: always
    volumes:
      - pg-data:/var/lib/postgresql/data/

  pgbouncer:
    image: edoburu/pgbouncer
    environment:
      - DB_HOST=postgredb
      - DB_PORT=5432
      - DB_USER=dbuser
      - DB_PASSWORD=dbpassword
      - ADMIN_USERS=postgres,admin     
    ports:
      - "5432:5432"

然后我像这样更改了微服务的连接字符串:

  commenting.api:
    environment:
      - ConnectionString=Server=pgbouncer;Port=5432;Database=commentDb;UId=dbuser;Password=dbpassword;Pooling=true;
    ports:
      - "5051:80"

  posting.api:
    environment:
      - ConnectionString=Server=pgbouncer;Port=5432;Database=postDb;UId=dbuser;Password=dbpassword;Pooling=true;
    ports:
      - "5052:80"

我得到这个错误

Npgsql.PostgresException: '08P01: server login failed: wrong password type'
.

到目前为止,我找到的最接近的配置是在这个存储库中edoburu/docker-pgbouncer

postgresql docker microservices connection-pooling pgbouncer
© www.soinside.com 2019 - 2024. All rights reserved.