Answer the question
In order to leave comments, you need to log in
How to properly connect psotgres in docker?
I am trying to wrap my laravel project in docker. Added containers: php-fpm, redis, nginx, php-worker, now I'm trying to add postgresql. In the docker-compose.yml file for docker, I wrote this:
db:
image: postgres:14-alpine
restart: always
networks:
- internal
environment:
- DB_CONNECTION=pgsql
- DB_HOST=postgres
- DB_PORT=5432
- DB_DATABASE=*db*
- DB_USERNAME=*username*
- DB_PASSWORD=*password*
- REDIS_HOST=127.0.0.1
- REDIS_PASSWORD=null
- REDIS_PORT=6379
volumes:
- ./docker/postgres/datadir:/var/lib/postgresql/data
database system is ready to accept connections
SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432? (SQL: select * from information_schema.tables where table_schema = public and table_name = options and table_type = 'BASE TABLE')
bind: address already in use
. Should I do the same with postgres, disable it before running containers?
Answer the question
In order to leave comments, you need to log in
Your project containers see the postgres container as db and not 127.0.0.1
For the same reason, you will have a problem with redis
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question