Я установил очень базовое c приложение rails, которое подключается к экземпляру postgres и экземпляру rails. По какой-то причине, когда я выполняю rails db:setup
, он не подключается к базе данных. Моя настройка ниже. Не думайте, что это может стать намного проще.
Важно отметить, что postgres запущен и готов принимать соединения.
docker -compose.yml
version: '3.4'
services:
postgres:
image: postgres
environment:
- POSTGRES_PASSWORD=password
volumes:
- ./tmp/postgres/data:/var/lib/postgres/data
redis:
image: redis
ports:
- '6379:6379'
web:
build:
context: .
target: development
command: tail -f /dev/null # I exec'ed in to run command
depends_on:
- postgres
- redis
env_file:
- ./docker-dev.env
ports:
- '3000:3000'
database.yml
development:
adapter: postgresql
encoding: unicode
pool: 5
username: postgres
password: password
host: postgres
Выход ошибки
D, [2020-04-03T03:20:34.562188 #32] DEBUG -- : using default configuration
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
Couldn't create 'hinge_test_db' database. Please check your configuration.
rails aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?