Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I have a debian wheezy server with apache2. The database is a docker container - standard postgres:9.1 with Port 5432 exposed to localhost:5434, data folder is in an own container connected via -v option.

Data-Container

docker run --name db-data -v /data -e PGDATA=/data -it --entrypoint /bin/bash postgres:9.1

Database-Container

docker run -d --name db -e POSTGRES_USER=name -e POSTGRES_PASSWORD=pwd -e PGDATA=/data -p 5434:5432 --volumes-from db-data postgres:9.1

I use a simple php script to test the connection:

$db = pg_connect("host=localhost port=5434 dbname=name user=name password=pwd connect_timeout=5");
if ($db) {
  echo pg_options($db);
} else {
  echo "error";
}

When I run this script via php info.php, I got following error after short waiting time:

PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: timeout expired in /var/www/start/info.php on line 2

  • I can connect via VPN and pgadmin from remote and local via telnet localhost 5434.
  • Also nmap -p 5434 localhost returns, that this Port is open.
  • I have installed php5-pgsql.
  • docker logs ... has no entries, even in fully debug mode

I would really appreciate any input!

share|improve this question
    
what does docker logs name-of-your-postgres-container say? – booyaa Apr 8 at 8:24
    
have you looked at the logs of the PostgreSQL container ? Just docker logs id_pgsqlshould show a few things . And you can get into the container with docker exec -it id_pgsql bash and debug locally – user2915097 Apr 8 at 8:25
    
activated debug logging via postgresql.conf, but nothing shows up, related to my connection tries... – farnzworld Apr 8 at 9:13
    
just for completeness sake can you also provide the docker run command you used to create your container? – booyaa Apr 8 at 12:20
    
is now in the question... – farnzworld Apr 9 at 13:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.