1
I migrated my application to a Docker container, it was working all right, until a moment I had to change the bank’s population scripts and recreate the bank, but I had this problem that I do not know how to solve, I tried to modify the ports, but I did not understand right.
Follow the error:
PHP Fatal error: Uncaught Exception 'Pdoexception' with message 'SQLSTATE[08006] [7] could not connect to server: Connection refused n tis the server running on host "localhost" (127.0.0.1) and Accepting n tTCP/IP Connections on port 5432? ncould not connect to server: Network is unreachable n tis the server running on host "localhost" (::1) and Accepting n tTCP/IP Connections on port 5432? ' in /app/library/Zend/Db/Adapter/Pdo/Abstract.php:129 nStack trace: n#0 /app/library/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__Construct('pgsql:host=loca...', 'postgres', '1234', Array) n#1 /app/library/Zend/Db/Adapter/Pdo/Pgsql.php(87): Zend_db_adapter_pdo_abstract->_connect() n#2 /app/library/Zend/Db/Adapter/Abstract.php(861): Zend_db_adapter_pdo_pgsql->_connect() n#3 /app/library/Zend/Db/Adapter/Pdo/Pgsql.php(171): Zend_db_adapter_abstract->quote('Casettings') n#4 /app/library/Zend/Db/Table/Abstract.php(836): Zend_db_adapter_pdo_pgsql->describeTable('Casettings', NULL) n#5 /app/library/Zend/Db/Table/Abstract.php(858): Zend_db_table_abstract->_setup in /app/library/Zend/Controller/Plugin/Broker.php on line 312
My Docker-Compose.yml version: '3'
services:
db:
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=1234
- POSTGRES_DB=saec_dev
image: postgres
restart: always
volumes:
- db-data:/var/lib/postgresql/data
- ./code/application/modules/db/sql/createDatabase.sql:/docker-entrypoint-initdb.d/createDatabase.sql
- ./code/application/modules/db/sql/populateDatabase.sql:/docker-entrypoint-initdb.d/populateDatabase.sql
ports:
- "5432:5432"
saec:
build: .
depends_on:
- db
ports:
- '40444:40444'
volumes:
- ./code:/app
volumes:
db-data:
Inside the application container -
saec
- no bank even, so you don’t have to connect inlocalhost
. Just change your connection string, changelocalhost
fordb
.– Bruno César
@Brunocésar Show, was exactly that.
– Vinicius Macelai