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!
docker logs name-of-your-postgres-container
say? – booyaa Apr 8 at 8:24docker logs id_pgsql
should show a few things . And you can get into the container withdocker exec -it id_pgsql bash
and debug locally – user2915097 Apr 8 at 8:25docker run
command you used to create your container? – booyaa Apr 8 at 12:20