2014-12-13 56 views
2

所以在這裏運行的命令啓動數據庫無法連接pgbouncer和Postgres與碼頭工人

sudo docker run --name mydb -e "POSTGRES_USER=user" -e "POSTGRES_PASSWORD=password" -t -d postgres 

這裏是pgbouncer

from ubuntu 
RUN apt-get update && apt-get -y install pgbouncer 
COPY /pgbouncer.ini /etc/pgbouncer/ 
COPY /userlist.txt /etc/pgbouncer/ 
EXPOSE 6543 

dockerfile這裏是pgbouncer設置

[databases] 
host = mydb 

[pgbouncer] 
pool_mode = session 
listen_addr = localhost 
listen_port = 6543 
auth_type = plain 
auth_file = userlist.txt 
user = postgres 

userlist.txt

「用戶」密碼「

因此,圖像建立良好。

sudo docker run -P -p 6543:6543 --name pgbouncer --link mydb:mydb -t leos/pgbouncer pgbouncer /etc/pgbouncer/pgbouncer.ini 

我用這個命令啓動它,我知道pgbouncer正在工作,因爲pgadmin試圖連接到數據庫。

而pgbouncer給了我這個輸出(由於某種原因,沒有說關於pgbouncer是否連接到數據庫)。

2014-12-13 12:28:28.937 1 ERROR host: syntax error in connstring 
2014-12-13 12:28:28.937 1 LOG File descriptor limit: 524288 (H:1048576), max_client_conn: 100, max fds possible: 110 
2014-12-13 12:28:28.937 1 LOG listening on ::1/6543 
2014-12-13 12:28:28.937 1 LOG listening on 127.0.0.1:6543 
2014-12-13 12:28:28.937 1 LOG listening on unix:/tmp/.s.PGSQL.6543 
2014-12-13 12:28:28.937 1 LOG process up: pgbouncer 1.5.4, libevent 2.0.21-stable (epoll), adns: evdns2 
2014-12-13 12:29:28.938 1 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us 
2014-12-13 12:30:28.939 1 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us 
2014-12-13 12:31:28.940 1 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us 
2014-12-13 12:32:28.941 1 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us 
2014-12-13 12:33:28.941 1 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us 

這裏是我能在pgAdmin的

Error: Error connecting to the server: server closed the connection unexpectedly 
    This probably means the server terminated abnormally 
    before or while processing the request. 

回答

0

這條線配置和碼頭工人OPTS並不corelated看到。

host = mydb 
--link mydb:mydb 

你應該閱讀關於 - 鏈接使用容器內。 您需要更新pgbouncer配置以及ENV提供的真實主機/端口--link