I am using docker-compose to build a small flask service and the database it uses. My docker-compose.yml looks something like this:
version: '3.7'
services:
database:
image: postgres:10.5
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
logging:
options:
max-size: 10m
max-file: "3"
ports:
- '5438:5432'
volumes:
- ./postgres-data:/var/lib/postgresql/data
- ./sql/schema.sql:/docker-entrypoint-initdb.d/schema.sql
web:
build: .
ports:
- "5000:5000"
depends_on:
- database
volumes:
- .:/code
environment:
- FLASK_APP=app.py
My app file uses some methods from another module that I try to import as usual and looks something like this
however, after I build both containers using
docker-compose up --build database web
everything seems to be working properly because I don't get any error messages, and it says:
- Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
but when I go to any that URL or any other route from my app it says that the connection was reset. Also using curl, this is all I get:
curl: (56) Recv failure: Connection reset by peer
so I have no idea what is wrong because like I said, I don't get any error messages or warnings