После запуска postgres на Docker любая попытка подключиться к базе данных приводит к следующему:
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Справочная информация об этой ошибке: http://sqlalche.me/e/e3q8
Я смотрел на подобные проблемы, и мои порты назначены как таковые;
ports:
- 5432:5432
Подробнее
- Сервер Flask с использованием venv
- Windows 10
Дополнительные детали
Dockerfile (для postgres)
FROM postgres:9.6-alpine
COPY init-db /docker-entrypoint-initdb.d/
файл заявки (FLASK_APP) ЭТО КОМАНДА, КОТОРАЯ РАЗРЫВАЕТ ЕГО
@application.cli.command(with_appcontext=True)
def create_db():
db.engine.execute("CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;")
db.drop_all()
db.create_all()
ИДЕНТИФИКАТОР КОНТЕЙНЕРА СОЗДАНИЕ ИМЯ СОЗДАННЫЕ ПОРТЫ СОСТОЯНИЯ
f04ca2725c96 taxai_ml "gunicorn --worker-c…" 3 часа назад Вверх на 3 часа 0.0.0.0:8900->5000/tcp taxai_ml_1
032fd31432af stripemock / stripe-mock "/ stripe-mock -http-…" 3 часа назад Up 3 часа 0.0.0.0:12111-12112->12111-12112/tcp taxai_stripe_1
795b2ff4d7d5 redis: 3.2.11-alpine "docker-entrypoint.s…" 3 часа назад Up 3 часа 0.0.0.0:6379->6379/tcp taxai_redis_1